Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Restore Qt.ItemFlags access as Qt.ItemFlag alias (PyQt6) #444

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions qtpy/QtCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@
# Alias deprecated ItemDataRole enum values removed in Qt6
Qt.BackgroundColorRole = Qt.ItemDataRole.BackgroundColorRole = Qt.BackgroundRole
Qt.TextColorRole = Qt.ItemDataRole.TextColorRole = Qt.ForegroundRole

# Alias for MiddleButton removed in PyQt6 but available in PyQt5, PySide2 and PySide6
Qt.MidButton = Qt.MiddleButton
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

# Add removed definition for `Qt.ItemFlags` as an alias of `Qt.ItemFlag` as PySide6 does.
# Note that for PyQt5 and PySide2 those definitions are two different classes
# (one is the flag definition and the other the enum definition)
Qt.ItemFlags = Qt.ItemFlag

elif PYSIDE2:
from PySide2.QtCore import *

Expand Down
8 changes: 7 additions & 1 deletion qtpy/tests/test_qtcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def test_enum_access():
assert QtCore.Qt.TextColorRole == QtCore.Qt.ItemDataRole.TextColorRole
assert QtCore.Qt.MidButton == QtCore.Qt.MouseButton.MiddleButton


@pytest.mark.skipif(PYSIDE2 and PYSIDE_VERSION.startswith('5.12.0'),
reason="Utility functions unavailable for PySide2 5.12.0")
def test_qtgui_namespace_mightBeRichText():
Expand All @@ -156,3 +155,10 @@ def test_qtgui_namespace_mightBeRichText():
See: https://doc.qt.io/qt-5/qt-sub-qtgui.html
"""
assert QtCore.Qt.mightBeRichText is not None


def test_itemflags_typedef():
"""
Test existence of `QFlags<ItemFlag>` typedef `ItemFlags` that was removed from PyQt6
"""
assert QtCore.Qt.ItemFlags is not None
Loading