Qt Qpushbutton设置背景色的问题
2015-01-11 22:13
966 查看
今天发现一个问题,Qt Qpushbutton设置背景色只能用代码如下设置,StyleSheet在qt creator中居然只能设置前景色!!!
pushbutton->setStyleSheet("background-color:rgb(234,234,234)");
如下使用palette也无法设置背景色!
QPalette P=pushbutton->palette();
P.setColor(QPalette::Window,Qt::green);
P.setBrush(QPalette::Window,Qt::blue);
P.setColor(QPalette::ButtonText,Qt::red);
pushbutton->setPalette(P);
pushbutton->setBackgroundRole(QPalette::Button);
pushbutton->setAutoFillBackground(true);
http://blog.chinaunix.net/uid-25808509-id-1746294.html
http://www.cppblog.com/qianqian/archive/2010/07/25/121238.html
pushbutton=new QPushButton(tr("返回"),this);
QPalette P=pushbutton->palette();
P.setColor(QPalette::Window,Qt::green);
P.setBrush(QPalette::Window,Qt::blue);
P.setColor(QPalette::ButtonText,Qt::red);
pushbutton->setPalette(P);
pushbutton->setBackgroundRole(QPalette::Button);
pushbutton->setAutoFillBackground(true);
pushbutton->setStyleSheet("background-color:rgb(234,234,234)");
// pushbutton->move(200,300);//设置子widget相对父widget中的位置
pushbutton->setGeometry(200,300,50,50);//设置子widget相对父widget中的位置及该widget的大小
相关文章推荐
- Qt 使用QPalette设置Qpushbutton背景色的问题
- QT QPushButton 通过stylesheet 设置样式
- Qt QPushButton 背景色
- Qt Qpushbutton美化问题
- 还是Qt 通过stylesheet或者palette设置背景色的问题
- 对QPushbutton背景设置palette无法生效的问题
- QT QPushButton 通过stylesheet 设置样式
- 还是Qt 通过stylesheet或者palette设置背景色的问题
- Qt QPushButton圆形图片设置为背景
- QT 设置QPushButton 颜色
- QT 设置QPushButton 颜色
- 在XML中定义Button、ImageButton、TextView的背景色设以及设置透明度
- Qt 设置背景色
- QT的一个奇怪问题,设置了Qt::Tool后,点击弹出对话框的确定取消按钮,程序直接退出。
- Qt——路径设置问题
- vs2008背景色设置的问题
- iOS6 Grouped类型UITableView背景色设置问题
- ie6 几个li上下排列会闪动的问题,嵌套div—外层div内层div都设置背景颜色,内层div背景色不显示的问题
- ul设置背景色看不到的问题
- qt字体设置问题