The toolset is hardcoded to work with PyQt5. However with the qtpy library, which unifies most of the syntax, most of the other qt versions can be loaded as simply as this:
os.environ["QT_API"] = os.environ.get("QT_API", "pyside2") # supports pyqt5, pyqt6, pyside2, pyside6
# Import the appropriate resources module based on the Qt bindings being used
import qtpy
if qtpy.API_NAME == "PySide2":
from toolset.rcc.resources_rc_pyside2 import qCleanupResources, qInitResources
elif qtpy.API_NAME == "PySide6":
from toolset.rcc.resources_rc_pyside6 import qCleanupResources, qInitResources
elif qtpy.API_NAME == "PyQt5":
from toolset.rcc.resources_rc_pyqt5 import qCleanupResources, qInitResources
elif qtpy.API_NAME == "PyQt6":
from toolset.rcc.resources_rc_pyqt6 import qCleanupResources, qInitResources
else:
raise ImportError(f"Unsupported Qt bindings: {qtpy.API_NAME}")
print(f"Using qt bindings '{qtpy.API_NAME}'")
from qtpy.QtWidgets import QApplication
app = QApplication(sys.argv)
As can be seen the 'QT_API' environment variable tells qtpy what qt version to use.
While we may not be planning to swap to another Qt version, this pr is still important as it allows further upgrades to be possible down the road, as qt5 is an ancient version.
PyQt5 isn't compatible with PyPy but PySide6 is.
This pr also updates the convertui.py script.
Caveats:
This requires migrating to a new settings. I'm unsure how to convert whatever QVariant already had in there safely to the new serialization system, the safest way is to migrate. Currently bad settings are throwing exceptions when the values are unrecognized...
This adds two packages to the toolset's requirements: jsonpickle and qtpy. Both are very lightweight packages and shouldn't need to be versioned afaik.
The toolset is hardcoded to work with PyQt5. However with the
qtpy
library, which unifies most of the syntax, most of the other qt versions can be loaded as simply as this:As can be seen the 'QT_API' environment variable tells qtpy what qt version to use.
While we may not be planning to swap to another Qt version, this pr is still important as it allows further upgrades to be possible down the road, as qt5 is an ancient version.
PyQt5 isn't compatible with PyPy but PySide6 is.
This pr also updates the
convertui.py
script.Caveats:
jsonpickle
andqtpy
. Both are very lightweight packages and shouldn't need to be versioned afaik.