[SOLVED (Not actually happening)] Return focus to parent when reaching last widget in tabOrder
-
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!
- TabWidget (and tab pages)
-
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();
}
@