QTableWidget: detect key that ended editing
-
wrote on 14 Jun 2024, 11:50 last edited by
I'm using a QTableWidget. I am wondering if it would be possible for me to detect which key it was that ended editing of a cell e.g.
- Tab, shift-Tab
- Arrow up/down
- Return
Thanks for any help.
-
I'm using a QTableWidget. I am wondering if it would be possible for me to detect which key it was that ended editing of a cell e.g.
- Tab, shift-Tab
- Arrow up/down
- Return
Thanks for any help.
wrote on 14 Jun 2024, 11:59 last edited by Pl45m4@faxmachine said in QTableWidget: detect key that ended editing:
I am wondering if it would be possible for me to detect which key it was that ended editing of a cell
With
QTableWidget
probably not, but when you have your ownQTableView
+ model class then you could emit your own, custom signal when the editing of a cell/data is finished and check the pressed key at the same time to send it via your signal.
In theory :)
Not tested, but I can imagine it might work like this.Or:
You use your own delegate editor widget and handle the editor events, which are able to handle exactly the keys you thought of.Returns true if the given editor is a valid QWidget and the given event is handled; otherwise returns false. The following key press events are handled by default:
Tab Backtab Enter Return Esc
If the editor's type is QTextEdit or QPlainTextEdit then Tab, Backtab, Enter and Return keys are not handled.
( https://doc.qt.io/qt-6/qstyleditemdelegate.html#eventFilter )
1/2