skg*_*skg 0 qt qt4 qmessagebox
我正在为我的屏幕创建一个错误消息框。我使用 QDialogButtonBox 作为按钮。现在我想用不同的颜色填充按钮。例如:“确定”--> 绿色“取消”--> 红色等。我可以更改所有按钮的背景,但不能单独更改。
有没有办法做到这一点?
提前致谢 !!!!
试试这个(使用 QDialogButtonBox::button() 和 QPushButton::setStyleSheet())。
QDialogButtonBox* buttonBox = new QDialogButtonBox;
// set up your button box
QColor okButtonColor = Qt::red;
buttonBox->button(QDialogButtonBox::Ok)->setStyleSheet(QString("background:%1").arg(okButtonColor.name()));
Run Code Online (Sandbox Code Playgroud)
编辑:在构建样式表字符串周围的代码中修复了错字。
| 归档时间: |
|
| 查看次数: |
2960 次 |
| 最近记录: |