Solved How to know that QTableView is in editing state
-
Hi, all
The different columns of QTableView have set delegates, the table model is QSqlTableModel, and everything is working normally. According to the needs of the project, when QTableView is idle, its background color will change randomly. When double-clicking any cell to enter the editing state, its background color will stop refreshing.
I tried the “hasFocus” property, “entered” signal, and “viewportentered” signal, but the Editing State cannot be obtained correctly.
How do I know if a cell in QTableView is being edited, please?
Best regards! -
@tovax said in How to know that QTableView is in editing state:
How do I know if a cell in QTableView is being edited, please?
In the delegate emit a signal just before returning from
setEditorData
-
@VRonin Hi, thank you very much for your reply, it solved my problem perfectly!
Best regards! -
If no delegation is used, how can this problem be solved?
-
@tovax said in How to know that QTableView is in editing state:
If no delegation is used, how can this problem be solved?
Overwrite QTableView::edit()
-
@Christian-Ehrlicher said in How to know that QTableView is in editing state:
Overwrite QTableView::edit()
@tovax
Plus see https://doc.qt.io/qt-5/qabstractitemview.html#closeEditor and https://doc.qt.io/qt-5/qabstractitemview.html#state. -
@Christian-Ehrlicher
@JonB
Thank you very much. -
@tovax said in How to know that QTableView is in editing state:
If no delegation is used,
A delegate is always used. The default one is
QStyledItemDelegate
so you can just subclass it and only add the signal