[PyQt] Working example of QMenuBar on OSX? Examples don't work

Marcel Maré list at webtothemax.com
Sat Jun 4 00:09:40 BST 2016


Hi All,

I could not find a working PyQt5.6 working example of the (system) menu bar on OS X.I have taken notice of the section “QMenuBar on OS X” in the docs (http://doc.qt.io/qt-5/qmenubar.html) but still couldn’t get it to work. 

I would expect this to work: 

self.menubar = QtWidgets.QMenuBar()  # note: no parent
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
mainwindow.setMenuBar(self.menubar)
self.actionQuit = QtWidgets.QAction(mainwindow)
self.actionQuit.setObjectName("actionQuit")
self.menuFile.addAction(self.actionQuit)
self.menubar.addAction(self.menuFile.menuAction())

What am I doing wrong?

PS I do not want to use “ setNativeMenuBar(False)”.

TIA 

Marcel




More information about the PyQt mailing list