Unsolved Tab Key Navigation with TableView and Buttons
-
Hi,
I have QWidget with a Tableview( 10 Rows) and 3 PushButtons (Reset, Cancel, Update).
Now I want to set the tab order like TableView - 10 rows( Should navigate through 10 rows), then Update, Cancel, Reset Buttons.
When I tried to implement the same, it is not working. Once the control goes inside the Tableview it does not comeout to QWidget.
Just set the TabOrder like TableView, Update Button, Cancel Button, Reset button.,
How to implement it?
-
Untested and
probablyhack-ish:QObject::connect(tableView->selectionModel(),&QItemSelectionModel::currentChanged,[=](const QModelIndex& idx)->void{ tableView->setTabKeyNavigation(!idx.isValid() || idx.row()<idx.model()->rowCount()-1 || idx.column()<idx.model()->columnCount()-1); });
The correct way is to subclass
QTableView
and reimplementkeyPressEvent
to override behaviour at line 2368 https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qabstractitemview.cpp.html#2368