[PyQt] connecting python code to a c++ signal

Phil Thompson phil at riverbankcomputing.com
Wed Oct 1 12:54:41 BST 2014


On 01/10/2014 12:04 pm, ale rimoldi wrote:
> hi
> 
> step by step, we are moving the scribus scripter to python3 and pyqt5.
> 
> currently, i'm stuck at a
> 
> """
> 'QObject' object has no attribute 'createMenu(QMainWindow*)'
> """
> 
> error.
> 
> 'createMenu' is a signal defined as
> 
> """
> signals:
> 	void createMenu(QMainWindow *mainwin);
> """
> 
> in
> https://github.com/aoloe/scribus-plugin-scripter/blob/master/src/scripterimpl.h#L75
> 
> and it's called as
> 
> """
> Scripter.connect("createMenu(QMainWindow*)", createMenu)
> """
> 
> in
> https://github.com/aoloe/scribus-plugin-scripter/blob/master/src/python/init_scripter.py#L98
> 
> 
> the c++ class is loaded through
> https://github.com/aoloe/scribus-plugin-scripter/blob/master/src/python/mikro.py
> 
> 
> 
> i'm not the original author of the scripter and i don't understand all
> the implementation details... but somebody has to do the port.
> 
> 
> does anybody have hints on how to solve this issue?
> 
> ciao
> a.l.e
> 
> 
> p.s.: hints on how to generally improve the scripter architecture are
> also welcome... but, first, i'd like to see it work again...

The modern equivalent call is...

Scripter.createMenu.connect(createMenu)

...assuming Scripter is an instance of a ScripterImpl object.

That syntax is supported by Python2 and PyQt4 so you might be better 
making all those changes first before trying Python3 and PyQt5.

Phil



More information about the PyQt mailing list