[PyQt] StyleSheet for Menu Button

Knacktus knacktus at googlemail.com
Fri Apr 22 06:22:24 BST 2011


Hi guys,

I've got a problem applying a stylesheet to a Menu Button. I expect the 
following code to apply a blue background to all widgets, including the 
Button for the menu. But it doesn't. Is it a bug or am I doing something 
wrong?

Cheers,

Jan

################################################################
import PyQt4.QtGui as QtGui

class MyMainWindow(QtGui.QMainWindow):

     def __init__(self, parent=None):
         super(MyMainWindow, self).__init__(parent)
         self.menu_bar = self.menuBar()
         self.session_menu = self.menu_bar.addMenu("&Session")

         self.setStyleSheet("""
         *
         {
             background-color: blue;
         }
         """)

if __name__ == "__main__":
     import sys
     app = QtGui.QApplication(sys.argv)
     main_window = MyMainWindow()
     main_window.show()
     app.exec_()


More information about the PyQt mailing list