I have made a QMessageBox in the following way:
msgBox.setText("Are you sure?");
msgBox.setStandardButtons(QMessageBox::Yes| QMessageBox::No);
msgBox.setStyleSheet("background-image: url(image)");
msgBox.exec();
Unfortunately using setStyleSheet on the messagebox sets the background for the buttons, the textbox and the actual msgbox. This is not wat I want. I want only the msgbox to have a background not the other components of the messagebox. I found out that using:
msgBox.button(QMessageBox::Yes)->setStyleSheet(...)
can be used to set the background on just the buttons. Is there a command with which I can set just the background of the msgBox, without adding a background to the buttons and the textbox?
You can limit to which elements the style will be applied by using a selector. So to only apply the style to the
QMessageBoxitself and not its children, you would use:For more details, see The Style Sheet Syntax – Selector Types.