alexandersv
22nd December 2010, 19:14
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:
void Dialog::criticalMessage()
{
QString title = tr( "Question" );
QMessageBox box( NULL );
box.setWindowTitle( title );
box.setText( "Question question question???????" );
//box.setStyleSheet("QPushButton { color: red }");
box.setIcon( QMessageBox::Critical );
box.setInformativeText( "sdkhfgkdfhgkdh" );
box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
box.button(QMessageBox::Ok)->setText("dkfhgkd");
int buttonClicked = box.exec();
}
5640
Here it is when un-commenting the setStyleSheet line from the code above:
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?
I tested this with the example from Qt called "standarddialogs", and modified the code at QDialog::criticalMessage()
Here is the QMessageBox without stylesheets:
void Dialog::criticalMessage()
{
QString title = tr( "Question" );
QMessageBox box( NULL );
box.setWindowTitle( title );
box.setText( "Question question question???????" );
//box.setStyleSheet("QPushButton { color: red }");
box.setIcon( QMessageBox::Critical );
box.setInformativeText( "sdkhfgkdfhgkdh" );
box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
box.button(QMessageBox::Ok)->setText("dkfhgkd");
int buttonClicked = box.exec();
}
5640
Here it is when un-commenting the setStyleSheet line from the code above:
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?