Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get a message when every time I move the map.

I had:

def info(self):
    QMessageBox.information( self, "Info" ),"info") )

I suppose that used to be something like that...

share|improve this question
By moved you mean moving the viewport, the position in the legend or the actual file/database where the layer/map is? – lynxlynxlynx Apr 21 '13 at 17:54
up vote 6 down vote accepted

What you are looking for is the extentsChanged() signal. This is emitted every time, the map canvas is moved or zoomed.

The following code works from the python console:

from PyQt4.QtGui import QMessageBox

def info():
    QMessageBox.information( iface.mapCanvas(), "Extents changed", "Pan or zoom occurred" )


Adjusting it to be used from a a python object (like in a plugin) should be easy, the necessary self-parameters are in the question code already.

There is no information about the new extents emitted with the signal, but this can be easily queried with

share|improve this answer
@underdark This should also work for QGIS 2.x, doesn't it? – Matthias Kuhn Sep 29 '13 at 9:14
The signal/slot mechanism has changed, see… – underdark Sep 30 '13 at 13:13
They are different use-cases available in both versions. The signal mentioned in this answer only gets emitted when the extent changes (pan / zoom) the other one gets emitted whenever the map canvas is repainted (e.g. symbology change). – Matthias Kuhn Sep 30 '13 at 13:30
sorry, my fault – underdark Sep 30 '13 at 18:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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