Skip to content

Qt6: Let Krita build with PyQt6 and port plugins

Freya Lupen requested to merge freyalupen/krita:freyalupen/pyqt6 into master

Let Krita build with PyQt6 and port all built-in plugins to it. Plugins aren't thoroughly tested and may still have bugs, but should mostly work.

This still needs the PyQt6 dep (and related sip, pyqt-builder, pyqt6-sip deps) to be ported in the deps repo.

Notes on building:

  • PyQt5.QtCore.PYQT_CONFIGURATION used by FindPyQt5.py is removed in PyQt6. Unsure where to get those variables from now or if they're needed.
  • Added a SIP Feature called Krita_Qt5 in order to ifdef Qt version in SIP files, by disabling the feature on Qt6. (Checking for QT_5_15_0 or QT_6_8_0 doesn't work as only 5x or 6x timelines are defined in each version.)
  • Some code in PythonPluginsModel::data fails to build on Qt6, I'm not sure why:
Undefined symbols for architecture x86_64:
  "KColorScheme::KColorScheme(QPalette::ColorGroup, KColorScheme::ColorSet, QExplicitlySharedDataPointer<KSharedConfig>)", referenced from:
      PythonPluginsModel::data(QModelIndex const&, int) const in libpykrita.a[x86_64][6](PythonPluginsModel.cpp.o)

Notes on porting plugins:

  • Used try/except to support both PyQt versions.
  • QAction is moved from QtWidgets to QtGui.
  • All of the following changes needed for PyQt6 also work on PyQt5:
    • PyQt5.Qt is removed, use PyQtX.QtCore.Qt (X being the appropriate version number).
    • qApp is removed, use QApplication.instance().
    • Using enum values now requires the enum name, for example , Qt.Horizontal -> Qt.Orientation.Horizontal or QDialogButtonBox.Ok -> QDialogButtonBox.StandardButton.Ok.
    • exec_() is now exec(), the conflicting exec keyword was removed in Python3.
    • QRegExp is replaced with QRegularExpression which requires rewritten code.
    • QFontMetrics().width() is replaced with QFontMetrics.horizontalAdvance().

Test Plan

  • Install PyQt6 into Krita's Python, build and run Qt6 Krita, test all built-in Python plugins.
  • Build and run Qt5 Krita, test all built-in Python plugins.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
  • Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?

Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.

Merge request reports

Loading