Graphics Reference
In-Depth Information
Deciphering the C++ documentation
As QGIS is implemented in C++, the documentation for QGIS APIs is all based on C++.
This can make it difficult for Python developers to understand and work with the QGIS
APIs. For example, the API documentation for the QgsInter-
face.zoomToActiveLayer() method:
If you're not familiar with C++, this can be quite confusing. Fortunately, as a Python pro-
grammer, you can skip over much of the complexity as it doesn't apply to you. In particu-
lar:
• The virtual keyword is an implementation detail you don't need to worry about
void indicates that the method doesn't return a value
• The double colons in QgisInterface::zoomToActiveLayer are simply a
C++ convention for separating the class name from the method name
Just like in Python, the parentheses show that the method doesn't take any parameters. So if
you have an instance of QgisInterface (for example, as the standard iface variable
available in the Python Console), you can call this method simply by typing the following:
iface.zoomToActiveLayer()
Now, let's take a look at a slightly more complex example: the C++ documentation for the
QgisInterface.addVectorLayer() method looks like the following:
Search WWH ::




Custom Search