1、对于同一个部件来说,只有最后一个setStyleSheet起作用(覆盖前面的设置),所以如果对组件设置样式,一次性全部设置完成
btn1->setStyleSheet("QPushButton{color:red}"); //设定前景颜色,就是字体颜色
btn1->setStyleSheet("QPushButton{background:yellow}"); //设定背景颜色为红色
//上面两句执行完毕后,btn1只修改了背景色为红色
btn1->setStyleSheet("QPushButton{color:red;background:yellow}");
//这句执行完毕,才是既修改字体颜色,也修改背景色
2、按钮的三种状态
未处于特殊状态、悬停、点击
btn1->setStyleSheet("QPushButton{color:red;background:yellow}"
"QPushButton::hover{background:rgb(110,115,100);}"
"QPushButton::pressed{background:#eb7350;}");
3、设置按钮的边框样式