Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Tab Key Navigation with TableView and Buttons
Forum Updated to NodeBB v4.3 + New Features

Tab Key Navigation with TableView and Buttons

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 665 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    inforathinam
    wrote on last edited by VRonin
    #1

    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?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      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 https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qabstractitemview.cpp.html#2368

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved