From bdbda260a0e1fdafcef2c8bf633cbcf14d90d040 Mon Sep 17 00:00:00 2001 From: Pierre Raybaut Date: Fri, 1 Mar 2024 18:41:58 +0100 Subject: [PATCH 1/2] Add QtCore.Qt.MouseButton.MidButton alias for Qt6 If QtCore.Qt.MidButton works with QtPy and Qt6, then QtCore.Qt.MouseButton.MidButton is expected to work as well. --- qtpy/QtCore.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qtpy/QtCore.py b/qtpy/QtCore.py index 09a42b1e..51791cf8 100644 --- a/qtpy/QtCore.py +++ b/qtpy/QtCore.py @@ -87,6 +87,7 @@ # Alias for MiddleButton removed in PyQt6 but available in PyQt5, PySide2 and PySide6 Qt.MidButton = Qt.MiddleButton + Qt.MouseButton.MidButton = Qt.MiddleButton # Add removed definition for `Qt.ItemFlags` as an alias of `Qt.ItemFlag` # passing as default value 0 in the same way PySide6 6.5+ does. @@ -142,6 +143,7 @@ ) = Qt.BackgroundRole Qt.TextColorRole = Qt.ItemDataRole.TextColorRole = Qt.ForegroundRole Qt.MidButton = Qt.MiddleButton + Qt.MouseButton.MidButton = Qt.MiddleButton # Map DeprecationWarning methods QCoreApplication.exec_ = lambda *args, **kwargs: possibly_static_exec( From 78d721e5ed950b6ea4bc9c2103fa58a9990022a7 Mon Sep 17 00:00:00 2001 From: dalthviz <16781833+dalthviz@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:48:13 -0500 Subject: [PATCH 2/2] Add assert for new button alias 'Qt.MouseButton.MidButton' --- qtpy/tests/test_qtcore.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qtpy/tests/test_qtcore.py b/qtpy/tests/test_qtcore.py index 4f981565..9044290d 100644 --- a/qtpy/tests/test_qtcore.py +++ b/qtpy/tests/test_qtcore.py @@ -188,6 +188,9 @@ def test_enum_access(): ) assert QtCore.Qt.TextColorRole == QtCore.Qt.ItemDataRole.TextColorRole assert QtCore.Qt.MidButton == QtCore.Qt.MouseButton.MiddleButton + assert ( + QtCore.Qt.MouseButton.MidButton == QtCore.Qt.MouseButton.MiddleButton + ) @pytest.mark.skipif(