Book Image

Building Mapping Applications with QGIS

By : Erik Westra
Book Image

Building Mapping Applications with QGIS

By: Erik Westra

Overview of this book

Table of Contents (16 chapters)
Building Mapping Applications with QGIS
About the Author
About the Reviewers
Free Chapter
Getting Started with QGIS

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 QgsInterface.zoomToActiveLayer() method:

If you're not familiar with C++, this can be quite confusing. Fortunately, as a Python programmer, you can skip over much of the complexity as it doesn't apply to you. In particular:

  • 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...