Skip to content

Commit b938c9d

Browse files
committed
Readd 'QAction' to QtWidgets with Qt version validation
1 parent 6643eac commit b938c9d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

qtpy/QtWidgets.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,20 @@ def __getattr__(name):
3737
elif PYQT6:
3838
from PyQt6 import QtWidgets
3939
from PyQt6.QtGui import (
40+
QAction,
4041
QActionGroup,
4142
QFileSystemModel,
4243
QShortcut,
4344
QUndoCommand,
4445
)
46+
47+
if parse(_qt_version) < parse("6.4"):
48+
# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4
49+
# See spyder-ide/qtpy#461
50+
from qtpy.QtGui import QAction
51+
else:
52+
from PyQt6.QtGui import QAction
53+
4554
from PyQt6.QtWidgets import *
4655

4756
# Attempt to import QOpenGLWidget, but if that fails,
@@ -110,9 +119,15 @@ def __getattr__(name):
110119
from PySide2.QtWidgets import *
111120
elif PYSIDE6:
112121
from PySide6.QtGui import QActionGroup, QShortcut, QUndoCommand
113-
from PySide6.QtWidgets import *
114122

115-
from qtpy.QtGui import QAction # See spyder-ide/qtpy#461
123+
if parse(_qt_version) < parse("6.4"):
124+
# Make `QAction.setShortcut` and `QAction.setShortcuts` compatible with Qt>=6.4
125+
# See spyder-ide/qtpy#461
126+
from qtpy.QtGui import QAction
127+
else:
128+
from PySide6.QtGui import QAction
129+
130+
from PySide6.QtWidgets import *
116131

117132
# Attempt to import QOpenGLWidget, but if that fails,
118133
# don't raise an exception until the name is explicitly accessed.

0 commit comments

Comments
 (0)