[Qgis-user] How to catch a QgsMapCanvas::emitExtentsChanged-signal?

Bernhard Seckinger bernhard.seckinger at bueffee.de
Thu Mar 14 07:48:22 PDT 2024


Hi,

I'm trying to write a plugin, that gets into action, whenever the user moves
or zooms the main map. I found the QgsMapCanvas::emitExtentsChanged() signal.
This is probably exactly, what I need. But I don't know, how to "catch" this
signal. I guess, this is somehow done with pyqtSignals, but I don't understand
how...

I found a tutorial (1) which explains how to use pyqtSignal with self defined
signals. I think I got this. But now I need to catch a signal which is defined
in the library. How to connect to this signal?

>From what I understand, my code should be something like:

def __init__():
    # with some pyqtSignal xxx:
    xxx.connect(my_fun)

def my_fun(some parameters?):
    # code to execute when extents changed

So two question remain:

a) What is xxx above?
b) Does "my_fun" need some parameters?

Any help is appreciated!

Thanks, Bernhard

(1) https://gis-ops.com/qgis-3-plugin-tutorial-pyqt-signal-slot-explained/

--
Bernhard Seckinger <bernhard.seckinger at bueffee.de>


More information about the QGIS-User mailing list