2 Attachment(s)
QMessageBox setStyleSheet UI problem
If I apply stylesheets to qApp or any QWidget that is parent of a QMessageBox (or QMessageBox directly), it looses the native look and feel on Mac (not sure other OSs because I haven't try with them).
I tested this with the example from Qt called "standarddialogs", and modified the code at QDialog::criticalMessage()
Here is the QMessageBox without stylesheets:
Code:
void Dialog::criticalMessage()
{
box.setWindowTitle( title );
box.setText( "Question question question???????" );
//box.setStyleSheet("QPushButton { color: red }");
box.setInformativeText( "sdkhfgkdfhgkdh" );
int buttonClicked = box.exec();
}
Attachment 5640
Here it is when un-commenting the setStyleSheet line from the code above:
Attachment 5639
As you can see, even if the stylesheet is not affecting QLabel, QMessageBox looses the bold question text and the description text's size is increased.
Is there a way to use stylesheets without loosing the Mac OS look and feel for QMessageBox?
Re: QMessageBox setStyleSheet UI problem
When you use style sheets you are by definition going away from the standard style.
In respect to the fact other properties change with out you really changing them, my guess is, that once you set a stylesheet, it will apply the properties explicitly changed by you, like the color in your case, and all the other properties will take some default value.
And my guess is, that the default value is not OS specific, but Qt Stylesheet specific - that means, that the text default is not bold, and it was set implicitly by the fact you set a style sheet.
But that is only a guess.
Re: QMessageBox setStyleSheet UI problem
Quote:
Originally Posted by
high_flyer
When you use style sheets you are by definition going away from the standard style.
In respect to the fact other properties change with out you really changing them, my guess is, that once you set a stylesheet, it will apply the properties explicitly changed by you, like the color in your case, and all the other properties will take some default value.
And my guess is, that the default value is not OS specific, but Qt Stylesheet specific - that means, that the text default is not bold, and it was set implicitly by the fact you set a style sheet.
But that is only a guess.
That makes sense. Thanks for your answer.
In case someone else experience this problem: the only way to have a QMessageBox that preserves the native look and feel, is by NOT applying the stylesheet to qApp (because it has a cascade effect on all windows) and make the parent of QMessageBox NULL (to avoid any cascading effect from a parent widget that has stylesheets).