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. [SOLVED (Not actually happening)] Return focus to parent when reaching last widget in tabOrder
Forum Updated to NodeBB v4.3 + New Features

[SOLVED (Not actually happening)] Return focus to parent when reaching last widget in tabOrder

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.1k 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.
  • D Offline
    D Offline
    Danielc
    wrote on last edited by
    #1

    Hi everybody!

    I created a class derived from QWidget and added an instance of it to a tab page. I just have one problem: When I 'enter' to that QWidget, I can't exit using the 'Tab' key. I want to return to the TabWidget (so I can change the page) when I press the 'Tab' key after completing the Tab Order.

    For example:

    • TabWidget (and tab pages)
      -- QWidget derived class
      --- 1. QLineEdit1
      --- 2. QLineEdit2
      --- 3. QComboBox1

    As for now, if I press 'Tab' I begin with TabWidget, then QWidget (with QLineEdit1). Once I am in QWidget, If I press 'Tab' I go to QLineEdit2, QComboBox1 and then QLineEdit1 again. I want that the 'Tab' key returns me to TabWidget after reaching QComboBox1.

    Is there any easy way to achieve this?

    Thanks and greetings!

    1 Reply Last reply
    0
    • L Offline
      L Offline
      ludde
      wrote on last edited by
      #2

      I think, by default, the focus really is supposed to go back to the tab widget when it reaches past the last item in the QWidget. So you should not have to do anything at all...

      The following little program works that way, at least for me, using Qt 4.7.4 on Windows:

      @
      #include <QtGui>
      #include "Widget.h"

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      QTabWidget tabWidget;

      QWidget *aWidget = new QWidget;
      QVBoxLayout *aLayout = new QVBoxLayout;
      aWidget->setLayout(aLayout);
      aLayout->addWidget(new QLineEdit);
      aLayout->addWidget(new QComboBox);
      tabWidget.addTab(aWidget, "A");
      
      QWidget *bWidget = new QWidget;
      QVBoxLayout *bLayout = new QVBoxLayout;
      bWidget->setLayout(bLayout);
      bLayout->addWidget(new QLineEdit);
      bLayout->addWidget(new QComboBox);
      tabWidget.addTab(bWidget, "B");
      
      tabWidget.show();
      return a.exec&#40;&#41;;
      

      }
      @

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Danielc
        wrote on last edited by
        #3

        Oh sorry. I just tried again and it works as supposed to work. Maybe I tested bad last time, I didn't notice the focus or there was another problem..

        Sorry.

        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