Skip to content

QGIS: Plugin development setup

OSGeo4W Setup

Visual Studio Code Setup

Interpreter

Set interpreter to python-qgis.bat or python-qgis-ltr.bat.

Plugin builder

Use Plugin Builder in QGIS.
Document on github.io

A typical plugin directory includes the following files:

  • metadata.txt - required - Contains general info, version, name and some other metadata used by plugins website and plugin infrastructure.
  • __init__.py - required - The starting point of the plugin. It has to have the :func:classFactory method and may have any other initialisation code.
  • mainPlugin.py - core code - The main working code of the plugin. Contains all the information about the actions of the plugin and the main code.
  • form.ui - for plugins with custom GUI - The GUI created by Qt Designer.
  • form.py - compiled GUI - The translation of the form.ui described above to Python.
  • resources.qrc - optional - An .xml document created by Qt Designer. Contains relative paths to resources used in the GUI forms.
  • resources.py - compiled resources, optional - The translation of the .qrc file described above to Python.

WARNING

If you plan to upload the plugin to the official_pyqgis_repository you must check that your plugin follows some additional rules, required for plugin official_pyqgis_repository_validation.

Credit @Wayne19980