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.,
    0_1525269196124_Screenshot from 2018-05-02 19:21:11.png

    How to implement it?

  • Untested and probably hack-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 reimplement keyPressEvent to override behaviour at line 2368

Log in to reply