[QGIS-Developer] Python slots don't get called when they're instance methods

Nyall Dawson nyall.dawson at gmail.com
Wed Nov 28 15:38:51 PST 2018


On Thu, 29 Nov 2018 at 09:32, G. Allegri <giohappy at gmail.com> wrote:
>
> 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)
>

Hmm - this code works fine for me!

class Foo():
  def __init__(self):
    QgsProject.instance().writeProject.connect(self.written)

  def written(self, dom):
    print('bah')

f=Foo()

This is on Linux (Fedora).

Nyall


More information about the QGIS-Developer mailing list