Qt Stylesheet for QMessageBox

16,070

Yes it is possible. The trick is to know how to select the sub-controls. Here's how you can change the style of the text, in this example I make the dialog grey and the text off-white:

QMessageBox {
    background-color: #333333;
}

QMessageBox QLabel {
    color: #aaa;
}

The second clause uses a Descendant Selector which in this case means "any QLabel that is a descendant of a QMessageBox including children and grandchildren etc". You can be more specific and only select children with QMessageBox > QLabel

I found this information here http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html

Share:
16,070
koan
Author by

koan

Interested in scientific computing, embedded applications, hardware optimisation.

Updated on June 04, 2022

Comments

  • koan
    koan almost 2 years

    I am using stylesheets. I want to set style information for the main message text and the informative text for a QMessageBox. Is it possible to access these sub-controls ?