Solved How to style each custom button in global QMessageBox styleSheet ?
-
I want to style each custom button of my QMessageBox in one stylesheet file without using setStyleSheet() for each button.
my QMessageBox style sheet:
QMessageBox { background-color:#dedede; } QLabel { color:#444; } QPushButton { border:2px solid #0076a3; border-radius:5px; color:#fff; background-color:#0898d8; padding:2px 25px; } QPushButton:hover:!pressed { border:1px solid #0076a3; } QPushButton:pressed { background-color:transparent; border:2px solid #444; color:#444; }
and i want style like:
QMessageBox { background-color:#dedede; } QLabel { color:#444; } QPushButton#oui { border:2px solid #0076a3; border-radius:5px; color:#fff; background-color:#0898d8; padding:2px 25px; } QPushButton#oui:hover:!pressed { border:1px solid #0076a3; } QPushButton#oui:pressed { background-color:transparent; border:2px solid #444; color:#444; } QPushButton#non { border:1px solid #444; border-radius:5px; color:#444; padding:2px 25px; background:transparent; } QPushButton#non:hover:!pressed { border:none; background-color:#0898d8; color:#fff; } QPushButton#non:pressed { border:2px solid #0076a3; color:#fff; background-color:#0898d8; }
QPushButton#oui and QPushButton#non are custom buttons added to QMessageBox.
-
@Christian-Ehrlicher,
it work well now as expected after i created my own dialog inherit QDialog and used setStyleSheet for the whole personal dialog. thank you for your help. -
Then set the stylesheet as global style sheet in QApplication
-
it seem work...
Why doesn't it work directly on QMessageBox setStyleSheet ()?
-
@Christian-Ehrlicher,
it work well now as expected after i created my own dialog inherit QDialog and used setStyleSheet for the whole personal dialog. thank you for your help.