Skip to content
Working Log – Zaiko Kanri
- Modifying from recognizing “Enter” key (‘\r’) is not as simple as thought
2025.04.15 (Tue), 2025.04.15 (Wed)
- The currently used approach for recognizing the “Enter” key
- overriding eventFilter
eventFilter(elf, object, event):
- event.type() == QEvent.KeyPress
- event.text() == u’\r’
- apparently there’s an “installEventFilter() to enable this eventFilter() ?
- e.g.
self.tblZaikoKanrihyou.installEventFilter(self)
self.txtSuuryou.installEventFilter(self)
- PROBLEM:
- TAB key is not captured/included in KeyPress event !!!
- solution in the internet that includes example that uses event.key()
- this event.key() is not existed in PySide, only in PyQt
- Search attempt: Key_Tab
- Related Documentation
- Failed attempt
- Approach 1
eventFilter(self, object, event)
- if object == self.tblDeetabeesu
- if event.type() == QEvent.FocusOut
- Why it failed during execution
- works quite normal & as expected UNTIL isnumeric() detection
self.tblDeetabeesu.item(dbRow, previousColumn).text().isnumeric()
- then it should be coming back to
self.tblDeetabeesu.edit(self.tblDeetabeesu.currentIndex())
- but it doesn’t
- the editing mode is suddenly off
- LET’S TRY OTHER APPROACH
- Approach 2
tblDeetabeesu_cellChanged(self)
- Why it failed during execution
- works well enough
- failed when user keep giving the same input, e.g.,
1st trial: ‘a’
2nd trial: ‘a’
- the cellChanged doesn’t recognize it as change (which is true)
- LET’S TRY OTHER APPROACH
- Approach 3
tblDeetabeesu_itemSelectionChanged(self)
- Problem:
- at the last cell
- when tab clicked, it moves to other cell, then start to process everything
- CURRENT CONCLUSION
- ENTER : eventFilter
- current cell is still in the edited cell (?)
- the first dbCol = 0
- TAB : cellChanged
- happens when the cell is already moved to the next cell
- the first dbCol = 0
- TAB : itemSelectionChanged
- happens when the cell is already moved
- the first column = 1!!!
- Can’t print header table UTF+8 (unreadable) to console/python console