QPushButton的应用

来源:互联网 发布:阿里云深圳机房 编辑:程序博客网 时间:2024/05/16 09:34

btn1->setStyleSheet("QPushButton{color:red}"); //设定前景颜色,就是字体颜色
btn1->setStyleSheet("QPushButton{background:yellow}"); //设定背景颜色为红色

btn1->setStyleSheet("QPushButton{color:red;background:yellow}");
第一个代码只能显示黄色背景,第二个确实红色字体,黄色背景,
所以当设定一个部件时候,要在同一个>setStyleSheet()中完全写出来。

 

//设置多种属性

exitBtn->setStyleSheet("QPushButton{color:red;background:yellow;font-size:20px}");

原创粉丝点击