Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.4.0
-
None
Description
When using a stacked widget in a QWidget and pressing tab focus is not set correctly.
I.E. if you have a QDialog containing several widgets, including a QStackedWidget and these are ordered in a layout; no matter where the stacked widget is placed all the other widgets will get focus before the stacked widgets children when tab is pressed.
If you have a button, a stacked widget and another button in a vertical layout, and also say that the stacked widget contains a QComboBox. If the top button has focus, and then tab is pressed, the focus will go to the bottom button before the combo box get focus. This is despite the fact that the combo box is placed in the middle of the window.
- How to reproduce:
1. Build and compile the code.
2. Start the application and press the tab key several times.
- Expected result:
Focus set in this order:
1. Top button
2. Combo box
3. Bottom button
- Actual result:
Focus set in this order:
1. Top button
2. Bottom button
3. Combo box
Test case main.cpp to reproduce issue using details above
============================================
#include <QtGui> class ConfigurationPage : public QWidget{ public: ConfigurationPage(QWidget *parent = 0); }; ConfigurationPage::ConfigurationPage(QWidget *parent): QWidget(parent){ QLabel *serverLabel = new QLabel(tr("Server:"),this); QComboBox *serverCombo = new QComboBox(this); serverCombo->addItem(tr("Trolltech (Australia)")); serverCombo->addItem(tr("Trolltech (Germany)")); QHBoxLayout *serverLayout = new QHBoxLayout; serverLayout->addWidget(serverLabel); serverLayout->addWidget(serverCombo); setLayout(serverLayout); } class ConfigDialog : public QDialog{ Q_OBJECT public: ConfigDialog(); QWidget *myWidget; QStackedWidget *stackedWidget; }; ConfigDialog::ConfigDialog(){ QPushButton *button = new QPushButton("test"); QPushButton *button2 = new QPushButton("test"); QPushButton *button3 = new QPushButton("test"); ConfigurationPage *p = new ConfigurationPage(); stackedWidget = new QStackedWidget(this); stackedWidget->addWidget(p); stackedWidget->setCurrentWidget( p ); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(button); layout->addWidget(button2); layout->addWidget(stackedWidget); layout->addWidget(button3); setLayout(layout); } int main(int argc, char *argv[]){ QApplication app(argc, argv); ConfigDialog mainWid; mainWid.show(); return app.exec(); } #include "main.moc"