Graphics Reference
In-Depth Information
QgsRubberBand : This draws an arbitrary polygon or polyline onto the map. It
is intended to provide visual feedback as the user draws a polygon onto the map.
QgsAnnotationItem : This is used to display additional information about a
feature, in the form of a balloon that is connected to the feature. The QgsAn-
notationItem class has various subclasses that allow you to customize the
way the information is displayed.
The QgsMapTool class
A map tool allows the user to interact with and manipulate the map canvas, capturing
mouse events and responding appropriately. A number of QgsMapTool subclasses
provide standard map interaction behavior such as clicking to zoom in, dragging to pan
the map, and clicking on a feature to identify it. You can also create your own custom map
tools by subclassing QgsMapTool and implementing the various methods that respond
to user-interface events such as pressing down the mouse button, dragging the canvas, and
so on.
Once you have created a map tool, you can allow the user to activate it by associating the
map tool with a toolbar button. Alternatively, you can activate it from within your Python
code by calling the mapCanvas.setMapTool(...) method.
We will look at the process of creating your own custom map tool in the section Using the
PyQGIS library .
Other useful qgis.gui classes
While the qgis.gui package defines a large number of classes, the ones you are most
likely to find useful are given in the following table:
Class
Description
This provides access to the map legend, that is, the list of map layers within the current project. Note that
map layers can be grouped, hidden, and shown within the map legend.
QgsLegendInterface
This displays a tip on a map canvas when the user holds the mouse over a feature. The map tip will show
the display field for the feature; you can set this by calling layer.setDisplayField("FIELD") .
QgsMapTip
QgsColorDialog
This is a dialog box that allows the user to select a color.
Search WWH ::




Custom Search