Customising QMessageBox



  • Hey,

    I am testing my application on a s60 device. Here i have noticed that the message Boxes displayed are very ugly. Using stylesheets is there any way that these can be customised? please provide a link to a sample code.



  • [quote author="mannu" date="1340254471"]Using stylesheets is there any way that these can be customised? [/quote]

    Yes, set the custom style using "QMessageBox's method setStyleSheet":http://qt-project.org/doc/qt-4.8/qwidget.html#styleSheet-prop which is inherited from QWidget.



  • [quote author="leon.anavi" date="1340257798"]
    [quote author="mannu" date="1340254471"]Using stylesheets is there any way that these can be customised? [/quote]

    Yes, set the custom style using "QMessageBox's method setStyleSheet":http://qt-project.org/doc/qt-4.8/qwidget.html#styleSheet-prop which is inherited from QWidget.
    [/quote]

    You can do it with QStyle childs (QGtkStyle, QWindowsStyle, QMotifStyle, etc) and QWidget::setStyle()



  • I've done something like the following, to make the message box look like the current stylesheet (which is available in my program through interface->mw->styleSheet(). In the stylesheet, I've set the button sizes, radii, colors etc.
    @ QMessageBox mb1;
    mb1.setStyleSheet(interface->mw->styleSheet());
    mb1.setMinimumSize(400, 300);
    mb1.setWindowFlags( Qt::FramelessWindowHint );
    mb1.setStandardButtons(QMessageBox::Ok);@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.