From 192dfe81852cc22488a4d7cb71ed7fe3127757c2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 21 Sep 2022 12:21:10 +1000 Subject: [PATCH] Get the runtime Qt version instead of the compile-time version PyQt sometimes bumps the Qt libraries without changing the Python side --- qt/aqt/about.py | 2 +- qt/aqt/qt/__init__.py | 7 ++++--- qt/aqt/utils.py | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qt/aqt/about.py b/qt/aqt/about.py index 79c2e758e..9197d7caa 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -108,7 +108,7 @@ def show(mw: aqt.AnkiQt) -> QDialog: abouttext += f"

{tr.about_version(val=version_with_build())}
" abouttext += ("Python %s Qt %s PyQt %s
") % ( platform.python_version(), - QT_VERSION_STR, + qVersion(), PYQT_VERSION_STR, ) abouttext += ( diff --git a/qt/aqt/qt/__init__.py b/qt/aqt/qt/__init__.py index c60601fa8..d3b1c7914 100644 --- a/qt/aqt/qt/__init__.py +++ b/qt/aqt/qt/__init__.py @@ -45,9 +45,10 @@ if os.environ.get("DEBUG"): sys.excepthook = info -qtmajor = (QT_VERSION & 0xFF0000) >> 16 -qtminor = (QT_VERSION & 0x00FF00) >> 8 -qtpoint = QT_VERSION & 0xFF +_version = QLibraryInfo.version() +qtmajor = _version.majorVersion() +qtminor = _version.minorVersion() +qtpoint = _version.microVersion() if qtmajor < 5 or (qtmajor == 5 and qtminor < 14): raise Exception("Anki does not support your Qt version.") diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 89ea157e7..8ba782913 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -73,6 +73,7 @@ from aqt.qt import ( qconnect, qtmajor, qtminor, + qVersion, traceback, ) from aqt.theme import theme_manager @@ -1089,7 +1090,7 @@ Add-ons, last update check: {} """.format( version_with_build(), platform.python_version(), - QT_VERSION_STR, + qVersion(), PYQT_VERSION_STR, platname, getattr(sys, "frozen", False),