File tree Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Original file line number Diff line number Diff line change 4
4
^^^^^
5
5
6
6
* 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 `).
Original file line number Diff line number Diff line change @@ -374,25 +374,16 @@ def contextMenuEvent(self, event):
374
374
def keyPressEvent (self , event ):
375
375
"""Reimplement Qt method"""
376
376
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 ()
392
377
# 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 :
394
379
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 :
396
387
self .edit (index )
397
388
else :
398
389
QTableView .keyPressEvent (self , event )
You can’t perform that action at this time.
0 commit comments