Tabbing through cellWidgets
-
Hi all.
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? -
[quote author="Antonio Di Monaco" date="1286817081"]
have you tried calling setTabKeyNavigation method?
@
your_table_widget->setTabKeyNavigation(true);
@[/quote]Hi,
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.
-
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.