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. Tabbing through cellWidgets
Forum Updated to NodeBB v4.3 + New Features

Tabbing through cellWidgets

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 7.4k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    Crazy Sage
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tony
      wrote on last edited by
      #2

      Hi,

      have you tried calling setTabKeyNavigation method? I.e.:

      @
      your_table_widget->setTabKeyNavigation(true);
      @

      Tony.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tony
        wrote on last edited by
        #3

        Btw, if not, please do it after removing all your "tries", otherwise there could be side effects.

        T.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          [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.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            BrianNewham
            wrote on last edited by
            #5

            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.

            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