File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# compat.py
22from qgis .PyQt .QtCore import QVariant
33
4- try :
4+ if hasattr (QVariant , "Int" ):
5+ # QGIS 3 / PyQt5: QVariant still exposes the legacy .Type enum members.
6+ # (QMetaType is importable under PyQt5 too, so we can't use that import
7+ # to detect QGIS 4 - checking for the attribute QGIS 4 actually removed
8+ # is the only reliable signal.)
9+ QVariantCompat = QVariant
10+ else :
11+ # QGIS 4 / PyQt6: QVariant.Type was removed; use QMetaType instead.
512 from qgis .PyQt .QtCore import QMetaType
613
714 # We create a proxy class to mimic the old QVariant.Type behavior
@@ -12,9 +19,6 @@ class QVariantProxy:
1219 Double = QMetaType .Type .Double
1320 String = QMetaType .Type .QString
1421 Bool = QMetaType .Type .Bool
22+ DateTime = QMetaType .Type .QDateTime
1523
16- # In QGIS 4, we use our proxy
1724 QVariantCompat = QVariantProxy
18- except (ImportError , AttributeError ):
19- # In QGIS 3, QVariant already has .Type
20- QVariantCompat = QVariant
You can’t perform that action at this time.
0 commit comments