- Release plans recap for the road to QGIS 1.0
- New version of eVis
- Contour Lines in Qgis
- QGIS and Google Summer of Code
- Quantum GIS Graduates OSGeo Incubation
- Paolo Cavallini Named to QGIS Project Steering Committee
- Nominations for QGIS PSC Open
- Capturing map coordinates in a stand alone app...
- Tutorial 7 - Creating spatial datasets with the QGIS API
- Html Image Plugin 0.2
Writing a QgsMapTool in Python
Submitted by spacedman on Thu, 2007-05-03 13:58.
For my project I need to give the user three ways to define a rectangular area: it can be the bounding box of a layer, it can be the current view area, or it can be defined by the user drawing a rectangle. My main dialog covers the first two options with a dropdown and a push button, but the third option meant writing a map tool - in Python of course!
The code and details are downloadable from my site.
In short, you create a new class that inherits from QgsMapTool, set the tool on the canvas to be your tool, and then just sit back as the user interacts with the tool via the events generated. It all worked pretty well first time in Python.
So, here's hoping people will build lots of useful map tools!
Barry
»
- spacedman's blog
- Add new comment
- 3342 reads

Recent comments
8 hours 54 min ago
1 day 4 hours ago
1 day 5 hours ago
1 day 7 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 11 hours ago
1 day 18 hours ago
1 day 20 hours ago
1 day 20 hours ago