diff --git a/scanslicer/main.py b/scanslicer/main.py index 37a2392..e3c2889 100644 --- a/scanslicer/main.py +++ b/scanslicer/main.py @@ -19,3 +19,27 @@ from .ui_builders import ScanSlicerUiBuilderMixin # _unwrap_qvariant: function definition for ScanSlicer behavior. +def _unwrap_qvariant(value): + unwrapped = value + for _ in range(4): + if hasattr(unwrapped, "variant"): + try: + candidate = unwrapped.variant() + except Exception: + candidate = unwrapped + if candidate is not unwrapped: + unwrapped = candidate + continue + + if hasattr(unwrapped, "value"): + try: + candidate = unwrapped.value() + except TypeError: + candidate = unwrapped.value + except Exception: + candidate = unwrapped + if candidate is not unwrapped: + unwrapped = candidate + continue + break + return unwrapped