Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions loopstructural/gui/compatibility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# compat.py
from qgis.PyQt.QtCore import QVariant

try:
if hasattr(QVariant, "Int"):
# QGIS 3 / PyQt5: QVariant still exposes the legacy .Type enum members.
# (QMetaType is importable under PyQt5 too, so we can't use that import
# to detect QGIS 4 - checking for the attribute QGIS 4 actually removed
# is the only reliable signal.)
QVariantCompat = QVariant
else:
# QGIS 4 / PyQt6: QVariant.Type was removed; use QMetaType instead.
from qgis.PyQt.QtCore import QMetaType

# We create a proxy class to mimic the old QVariant.Type behavior
Expand All @@ -12,9 +19,6 @@ class QVariantProxy:
Double = QMetaType.Type.Double
String = QMetaType.Type.QString
Bool = QMetaType.Type.Bool
DateTime = QMetaType.Type.QDateTime

# In QGIS 4, we use our proxy
QVariantCompat = QVariantProxy
except (ImportError, AttributeError):
# In QGIS 3, QVariant already has .Type
QVariantCompat = QVariant
Loading