0

I want to chanhe the background colour and font of QMessageBox button? Any help will be greatly appreciated.

4

1 回答 1

2
#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

于 2016-02-10T06:40:19.007 回答