Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Stylesheet for QMessageBox

Tags:

stylesheet

qt

qt4

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 ?

like image 264
koan Avatar asked Sep 02 '26 19:09

koan


1 Answers

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

like image 108
James Avatar answered Sep 05 '26 14:09

James