1

I'm trying to connect to the crsChanged signal in PyQGIS and each time I try to connect to it, I get the following error:

() missing 1 required positional argument: 'x'

The relevant pieces of code are:

self.project = QgsProject.instance()
self.project.crsChanged.connect(self.crsFx)

def crsFx(self):
    print('Changing Crs')
    self.crs = self.iface.mapCanvas().mapSettings().destinationCrs().authid()
    print(self.crs)
0
1

This small example works for me. It is simpler to user project instance.

def cc():
    project = QgsProject.instance()
    print(project.crs().authid())

project = QgsProject.instance()
project.crsChanged.connect(cc)
2
  • 1
    Excellent @Zoltan. That worked great. Just wondering how did you figure that out? From the documentation, I was unable to. Thanks Nov 25 '20 at 15:21
  • Years and the experience ... :)
    – Zoltan
    Nov 25 '20 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.