Updated Plugin migration to be compatible with Qt5 and Qt6 (markdown)

Étienne Trimaille 2025-01-08 14:06:00 +01:00
parent 5419540ace
commit 27f909d1cd

@ -8,6 +8,7 @@ It's possible to make a plugin for both Qt5 and Qt6.
1. `pip install astpretty tokenize-rt`
1. Install `python3-pyqt6`, `python3-pyqt6.qtsvg`, `python3-pyqt6.qsci`
1. Download the script available on [GitHub](https://github.com/qgis/QGIS/blob/master/scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py)
1. You should check that `PyQt5` is not available in the Python environment, the script will work better
1. `pyqt5_to_pyqt6.py /path/to/plugin`
1. Edit the `metadata.txt` by adding `supportsQt6=True`
@ -21,13 +22,11 @@ This will get you in the right direction but might not do all necessary changes.
- e.g. [QAction has moved to QtGui](https://doc.qt.io/qt-6/widgets-changes-qt6.html#qaction-qactiongroup)!
- [Qt Namespace](https://doc.qt.io/qt-6/qt.html), all enums in Qt
## Manual checks
## Manual conversion
Using the link above about [Qt Namespace](https://doc.qt.io/qt-6/qt.html), enum must changed accordingly.
To make a code working for both versions, it's mostly about how enums are called. For instance, according to [Qt Namespace](https://doc.qt.io/qt-6/qt.html) :
For instance :
PyQt5 | PyQt6
Working only in PyQt5 | Working for both PyQt5 and PyQt6
:---: | :---:
Qt.UserRole | Qt.ItemDataRole.UserRole
Qt.WaitCursor | Qt.CursorShape.WaitCursor