QPalette set QMenubar background is not working
Solved
General and Desktop
-
see:
app = QApplication(sys.argv) window = QWidget() menubar = QMenuBar(window) menubar.setAutoFillBackground(True) palette = menubar.palette() palette.setColor(palette.ColorRole.Button, Qt.GlobalColor.blue) # this line palette.setColor(palette.ColorRole.Window, Qt.GlobalColor.red) # this line palette.setColor(palette.ColorRole.ButtonText, Qt.GlobalColor.green) menubar.setPalette(palette) menu = QMenu('File') menubar.addMenu(menu) window.show() if __name__ == '__main__': sys.exit(app.exec())
result:
this result background is no change
i'm beginner,
this why is this result, can't use qpalette on the menubar, use it on the qwidget is good, on the qtoolbar is good, why.
i don't want use to stylesheet.
help me please, thanks!