During the porting of a plugin to QGIS 3.x I'm facing the following when
using Qgs* objects' signals (it doesn't happen with Qt widgets, etc.).
I'm using QGIS 3.4 on Window 10.
If I have a Python class like the following:
>class Foo():
> def __init__(self):
> QgsProject.instance().writeProject.connect(self.written)
>
> def written(self, dom):
> (do something)
self.written is never called. The signal can only connected to unbound
methods, e.g. to a top level def function or a class method. If I write:
>class Foo():
> def __init__(self):
> QgsProject.instance().writeProject.connect(Foo.written)
>
> def written(dom):
> (do something)
it works, but in general I cannot make make all my methods class methods of
course!
I've also tried making Foo derive from QObject. I've also tried decorating
"def writter" as a pyQtSlot, but nothing worked.
Is it only me, is it expected or is it a (known) bug?
In case it's the expected behaviour I wonder I the old classe signals like
I used to write:
>QObject.connect(QgsProject.instance(),SIGNAL('writeProject (QDomDocument
&)'),self.written)
could be ported to QGIS 3
Cheers,
Giovanni
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer