我想了解QMessageBox按钮的背景颜色和字体吗?任何帮助将不胜感激。
#include <QtWidgets>
int main(int argc,char* argv[])
{
QApplication app(argc,argv);
QMessageBox msgBox(QMessageBox::Information,
"QMessageBox Background Color",
"This is QMessageBox with Different Background Color");
//Change background color
QPalette palette;
palette.setColor(QPalette::Background, Qt::cyan);
msgBox.setPalette(palette);
//Change font
QFont font( "Tokyo" );
font.setPointSize( 32 );
font.setWeight( QFont::Bold );
font.setItalic( TRUE );
msg->setFont(font);
msg->exec();
msgBox.show();
return app.exec();
}
有关样式表的更多信息 http://doc.qt.io/qt-4.8/stylesheet-syntax.html