mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-25 00:04:25 -04:00
Updated Plugin migration to QGIS 3 (markdown)
parent
153be6efc8
commit
a039032ed2
@ -1,12 +1,17 @@
|
||||
While you are porting/rewriting your plugin, think about using QGIS native widgets. For instance, if you need a combobox providing a list of layers, use a `QgsMapLayerComboBox` instead of a `QComboBox`. There is also `QgsFieldComboBox` if you need to pick a field in a vector layer. The full list of widgets is here https://qgis.org/pyqgis/master/gui/index.html. It's less code to write for you, and users will have the same user experience across plugins and QGIS Desktop.
|
||||
## Recommendations
|
||||
|
||||
Also think about using the Processing framework. Your plugin can become its own Processing provider so your algorithms can be included in models and have the same UI as native algorithms. It's also less code to write, the UI is managed by QGIS. In QGIS 3, Processing has been refactored and is much more powerful than in QGIS 2.
|
||||
* While you are porting/rewriting your plugin, think about using QGIS native widgets. For instance, if you need a combobox providing a list of layers, use a `QgsMapLayerComboBox` instead of a `QComboBox`. There is also `QgsFieldComboBox` if you need to pick a field in a vector layer. The full list of widgets is here https://qgis.org/pyqgis/master/gui/index.html. It's less code to write for you, and users will have the same user experience across plugins and QGIS Desktop.
|
||||
|
||||
In QGIS 3, GeoPackage is much more present. Avoid creating shapefile in your plugin if possible and use the OGC standard GeoPackage format which can store both raster and vector in a single file: http://www.geopackage.org
|
||||
* Use `from qgis.PyQt.QtCore import QDir` for instance instead of `from PyQt5.QtCore import QDir` in your code. So it's less code to update when QGIS will use a newer Qt version. It works for other Qt modules.
|
||||
|
||||
Note that you can easily provide one version for QGIS 2 and QGIS 3 at the same time. Fill you metadata.txt correctly with `qgisMinimumVersion` and `qgisMaximumVersion`. The plugin manager will automatically ship the highest version based on the QGIS version.
|
||||
* Think about using the Processing framework. Your plugin can become its own Processing provider so your algorithms can be included in models and have the same UI as native algorithms. It's also less code to write, the UI is managed by QGIS. In QGIS 3, Processing has been refactored and is much more powerful than in QGIS 2.
|
||||
|
||||
* In QGIS 3, GeoPackage is much more present. Avoid creating shapefile in your plugin if possible and use the OGC standard GeoPackage format which can store both raster and vector in a single file: http://www.geopackage.org
|
||||
|
||||
* Note that you can easily provide one version for QGIS 2 and QGIS 3 at the same time. Fill you metadata.txt correctly with `qgisMinimumVersion` and `qgisMaximumVersion`. The plugin manager will automatically ship the highest version based on the QGIS version.
|
||||
|
||||
## Plugin location on file system
|
||||
|
||||
While in QGIS 2, plugins were located in your home directory in the `.qgis2/python/plugins` folder. In QGIS 3, this folder is now in a specific QGIS profile. You can find this folder by going to `Settings` -> `User profiles` -> `Open Active Profile folder`. You will find `python/plugins`.
|
||||
|
||||
## Minimal info
|
||||
|
Loading…
x
Reference in New Issue
Block a user