[PyQt] Create QMenus in different files

Alain Muls alain.muls at gmail.com
Fri Nov 17 18:53:14 GMT 2017


Hi All

I just started out with pyQt5 but I have experience with Qt and C++.

I try to separate my code in different files for not getting files that 
are too long. Therefor I am looking to a way that I can create the 
different QMenus (so 'file', 'edit', 'Help', etc) in separate files. I 
tried several things

  * subclassing QMenu and then create in the main GUI part an instance
    that I add to the QMenuBar

  * create a function in a different file that returns a QMenu that I
    add to the QMenuBar

but both methods didn't show the added menu in my menubar.

The first method had as problem that the derived class was not a QMenu, 
so could not be added.

I tried second methods since in the documentation of QMenuBar I found:

QAction*addMenu 
<http://pyqt.sourceforge.net/Docs/PyQt4/qmenubar.html#addMenu>*(/self/, 
QMenu /menu/)

So it should be possible to add a QMenu (second method).

Does someone has such an example?

Tx for your help

Alain

-- 

	
*Alain Muls*
/Professor/
Department CISS
*Royal Military Academy*
p: 	+32 244 13936
a: 	Renaissance Avenue 30
	B1000 Brussels (Belgium)
w: 	www.rma.ac.be/ciss/en/ <http://www.rma.ac.be/ciss/en/> e: 
alain.muls at rma.ac.be <mailto:alain.muls at rma.ac.be>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171117/8008e14e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logorma-transparent-scaled.png
Type: image/png
Size: 3940 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171117/8008e14e/attachment.png>


More information about the PyQt mailing list