按钮的背景颜色是rgb(240, 108, 96),边框是1像素宽的rgba(113, 17, 15,50)颜色的实线边框,边框的圆角半径为6像素。 QPushButton:hover { background-color:rgb(139, 29, 31) } 这部分定义了按钮在鼠标悬停(hover)状态下的外观。当鼠标悬停在按钮上时,按钮的背景颜色将变为rgb(139, 29, 31) 。 QPus...
m_closeBtn = new QPushButton(this); m_closeBtn->setFixedSize(32, 32); m_closeBtn->setStyleSheet("QPushButton{background-image:url(:/_3_ListWidgetPro/resources/titlebar/close.svg);border:none}" \ "QPushButton:hover{" \ "background-color:rgb(99, 99, 99);" \ "background-image:url(:...
上例中,QPushButton#okButton比QPushButton要更具体,因为QPushButton#okButton指向单个的对象,而不是类的所有实例。 类似,伪选择器比未指定伪状态的选择器更具体。因而,以下样式表指定,当鼠标悬停在QPushButton上时,QPushButton的文本为白色,否则为红色。 QPushButton:hover { color: white } QPushButton { col...
"QPushButton:pressed{border-image:url(:/new/prefix1/image/showmodeimag/ok1.png);}"); 也可以在 QtDesigner 上,即ui文件上的按钮处编辑样式表,如下图所示: 样式表如下: QPushButton{border-image: url(:/new/prefix1/image/showmodeimag/ok.png)} QPushButton:hover{border-image: url(:/new/prefi...
QPushButton{ background:white; border-radius:15px; } QPushButton:hover{ background:#333; border-radius:15px; background:#49ebff; } QLineEdit{ background:transparent; border:none; color:#717072; border-bottom:1px solid #717072; }
3 按钮被鼠标滑过的时候样式,代码如下:QPushButton#pushButton:hover{ background-color: qconicalgradient(cx:0.5, cy:0.522909, angle:179.9, stop:0.494318 rgba(181, 225, 250, 255), stop:0.5 rgba(222, 242, 251, 255)); border-radius:5px; border: 1px solid #3C80B1; }效果如下:4 ...
我们在Qt Designer中使用的按钮控件,QPushButton,QToolButton,QRadioButton,QCheckBox (其中QRadioButton和QCheckBox类是勾选按钮,QPushButton和QToolButton类是点击按钮,可以切换行为)等都是通过继承QAbstractButton,都会获得以上属性。这些按钮类一些默认属性是不同的,例如例如QRadioButton和QCheckBox默认是Checkable(),是...
QPushButton:hover:pressed{\ background:#1874CD; \ }");returna.exec(); } 3,从样式文件加载 一般我把样式文件写到.css格式后缀的文本文件中,因为notepad++可以识别该格式打开,能很方便的带颜色显示和编辑。 放到程序目录的单独的qss文件夹内,就像配置文件一样。
按钮QPushButton的样式设计,包括默认状态、鼠标悬停状态以及被按下状态的外观,如:QPushButton { background-color: rgb(240, 108, 96);border:1px solid rgba(113, 17, 15,50);border-radius:6px; } QPushButton:hover { background-color:rgb(139, 29, 31)} QPushButton:pressed { back...
1.先说第一种,直接在Qt Designer 中添加样式。 这种方式的优点就是快,直接,缺点也很明显,就是只能设定一次,应用在固定不变的ui上,这种方法是首选,但是当需要根据当前操作做出对应的变化,第一种方法就不行了,例如按一下按钮变一种颜色,或者调节参数,这时我们就需要第二种方法。