Skip to content

Commit 5fc656f

Browse files
committed
Handle qsm bindings missing from most pyqt6 versions
1 parent 1d7e5ab commit 5fc656f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

qtpy/QtStateMachine.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
QMouseEventTransition,
4646
)
4747
elif PYQT6:
48-
from PyQt6.QtStateMachine import *
48+
from PyQt6.QtCore import PYQT_VERSION_STR
49+
50+
if int(PYQT_VERSION_STR.split(".")[1]) >= 9:
51+
from PyQt6.QtStateMachine import *
52+
else:
53+
from . import QtBindingInNewerVersionError
54+
55+
raise QtBindingInNewerVersionError(name="QtStateMachine")
4956
elif PYSIDE6:
5057
from PySide6.QtStateMachine import *

qtpy/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class QtBindingMissingModuleError(QtModuleNotFoundError):
125125
_msg_extra = "It is not currently implemented in {binding}."
126126

127127

128+
class QtBindingInNewerVersionError(QtModuleNotFoundError):
129+
"""Raised when a module is only supported in newer versions of a binding."""
130+
131+
_msg_extra = "It is only available in newer versions of {binding}."
132+
133+
128134
class QtModuleNotInstalledError(QtModuleNotFoundError):
129135
"""Raise when a module is supported by the binding, but not installed."""
130136

0 commit comments

Comments
 (0)