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

Marcel Maré list at webtothemax.com
Sat Jun 4 21:53:52 BST 2016


Hi Vincent

I should have been a bit clearer: menus defined in code or in the Designer *do* show up in the OSX system menu. However they seem disabled: clicking on the menus does not do anything. 
This is also the case with all PyQt menu-related examples. So it is not related to my code. 

Running PyQt 5.6 and python 3.5.1.

Marcel 

> On 04 Jun 2016, at 07:11, Vincent Vande Vyvre <vincent.vande.vyvre at telenet.be> wrote:
> 
> Le 04/06/2016 01:09, Marcel Maré a écrit :
>> 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
>> 
>> 
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> Hi,
> 
> Are you sure you have set the text of the menu and the action ?
> 
> No text, no visibility.
> 
> Vincent
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt




More information about the PyQt mailing list