Skip to content

Commit

Permalink
PR: Add QtCore.Qt.MouseButton.MidButton alias for Qt6 (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 authored Oct 24, 2024
2 parents cc54a5e + 78d721e commit 2cc5fc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qtpy/QtCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions qtpy/tests/test_qtcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2cc5fc4

Please sign in to comment.