Skip to content

Commit 7c80d93

Browse files
committed
Handle QUndoStack compatibility between Qt5 and Qt6
1 parent 03f38d2 commit 7c80d93

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

qtpy/QtGui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __getattr__(name):
6161
QFileSystemModel,
6262
QShortcut,
6363
QUndoCommand,
64+
QUndoStack,
6465
)
6566

6667
elif PYQT6:
@@ -116,6 +117,7 @@ def __getattr__(name):
116117
QFileSystemModel,
117118
QShortcut,
118119
QUndoCommand,
120+
QUndoStack,
119121
)
120122

121123
if hasattr(QFontMetrics, "horizontalAdvance"):

qtpy/QtWidgets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __getattr__(name):
4242
QFileSystemModel,
4343
QShortcut,
4444
QUndoCommand,
45+
QundoStack,
4546
)
4647

4748
if parse(_qt_version) < parse("6.4"):
@@ -118,7 +119,7 @@ def __getattr__(name):
118119
elif PYSIDE2:
119120
from PySide2.QtWidgets import *
120121
elif PYSIDE6:
121-
from PySide6.QtGui import QActionGroup, QShortcut, QUndoCommand
122+
from PySide6.QtGui import QActionGroup, QShortcut, QUndoCommand, QUndoStack
122123

123124
if parse(_qt_version) < parse("6.4"):
124125
# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4

qtpy/tests/test_qtgui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_what_moved_to_qtgui_in_qt6():
6161
assert QtGui.QFileSystemModel is not None
6262
assert QtGui.QShortcut is not None
6363
assert QtGui.QUndoCommand is not None
64+
assert QtGui.QUndoStack is not None
6465

6566

6667
def test_qtextdocument_functions(pdf_writer):

qtpy/tests/test_qtwidgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_what_moved_to_qtgui_in_qt6():
4444
assert QtWidgets.QFileSystemModel is not None
4545
assert QtWidgets.QShortcut is not None
4646
assert QtWidgets.QUndoCommand is not None
47+
assert QtWidgets.QUndoStack is not None
4748

4849

4950
def test_qplaintextedit_functions(qtbot, pdf_writer):

0 commit comments

Comments
 (0)