Skip to content

Commit f803fa5

Browse files
committed
FIX: fix keyboard navigation issues on PyQt6 (closes #235)
This whole QKeySequence code wasn't even used (it was probably necessary for qt4)
1 parent 5337f44 commit f803fa5

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

doc/source/changes/version_0_34_1.rst.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Fixes
44
^^^^^
55

66
* fixed viewer being inusable in a script run via PyCharm "run with console" (closes :editor_issue:`253`).
7+
8+
* fixed keyboard navigation when using PyQt6 (closes :editor_issue:`235`).

larray_editor/arraywidget.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -374,25 +374,16 @@ def contextMenuEvent(self, event):
374374
def keyPressEvent(self, event):
375375
"""Reimplement Qt method"""
376376

377-
# comparing with the keysequence and not with event directly as we
378-
# did before because that only seems to work for shortcut
379-
# defined using QKeySequence.StandardKey, which is not the case for
380-
# Ctrl + E
381-
# FIXME: this is no longer supported by PyQt6
382-
# TypeError: unsupported operand type(s) for |: 'KeyboardModifier' and 'int'
383-
keyseq = QKeySequence(event.modifiers() | event.key())
384-
if keyseq == QKeySequence.Copy:
385-
self.copy()
386-
elif keyseq == QKeySequence.Paste:
387-
self.paste()
388-
elif keyseq == QKeySequence.Print:
389-
self.parent().plot()
390-
elif keyseq == "Ctrl+E":
391-
self.to_excel()
392377
# allow to start editing cells by pressing Enter
393-
elif event.key() == Qt.Key_Return and not self.model().readonly:
378+
if event.key() == Qt.Key_Return and not self.model().readonly:
394379
index = self.currentIndex()
395-
if self.itemDelegate(index).editor_count == 0:
380+
try:
381+
# qt6
382+
delegate = self.itemDelegateForIndex(index)
383+
except AttributeError:
384+
# qt5
385+
delegate = self.itemDelegate(index)
386+
if delegate.editor_count == 0:
396387
self.edit(index)
397388
else:
398389
QTableView.keyPressEvent(self, event)

0 commit comments

Comments
 (0)