Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Tabbing through cellWidgets
Crazy Sage last edited by
Do someone know, about handling tabbing order for QTable cellwidgets in Qt?
I've tried to do setTabOrder(table->cellWidget(row,col-1),table->cellWidget(row,col)) for each added cellWidget.
I've tried to make list of cellwidgets and create eventFilter for table and all cellWidgets to catch all key press events with tab.
I've tried to set focusPolicy to QWidget::NoFocus for my table.
And still when I press tab focus moves to first cellWidget, then to second, then it comes to loop and I can't move focus from cellWidget to any other widget on the form without mouse.
What am I doing wrong?
tony last edited by
have you tried calling setTabKeyNavigation method? I.e.:
tony last edited by
Btw, if not, please do it after removing all your "tries", otherwise there could be side effects.
Guest last edited by
[quote author="Antonio Di Monaco" date="1286817081"]
have you tried calling setTabKeyNavigation method?
By default this is enabled, and set to true. With this value as true, the behavior reported by Crazy Sage is seen. i.e. on tab key, the focus keeps looping within the QTableWidget cells.
If you set it to false, on tab key, the focus jumps to other widgets in the form. But then you cannot navigate to the cells in the QTableWidget using the keyboard.
So, I think if you want to press Tab key to navigate within the table, but only for the top left and bottom right cells, you want to move out of the table to other widgets in the form, then you have to override QTableWidget and build in this behavior.
BrianNewham last edited by
I subclassed QTableWidget.
When setting widgets for each cell I called Widget->installEventFilter(this); for each widget.
On the class derived from QTableWidget I implemented
bool eventFilter(QObject *object, QEvent *event) and looped through Rows and Columns calling cellWidget(Row,Col) until object was found. I then called setCurrentCell(Row,Col) to continue the tabbing order from each mouse press.