void tst_QStackedWidget::dynamicPages() { QStackedWidget *sw = new QStackedWidget; TestPage *w1 = new TestPage(true); w1->setN(3); TestPage *w2 = new TestPage; w2->setN(3); sw->addWidget(w1); sw->addWidget(w2); QLineEdit *le11 = w1->findChild<QLineEdit*>(QLatin1String("lineEdit1")); le11->setFocus(); // set focus to second widget in the page sw->resize(200, 200); sw->show(); qApp->setActiveWindow(sw); QTest::qWaitForWindowActive(sw); QTRY_COMPARE(QApplication::focusWidget(), le11); sw->setCurrentIndex(1); QLineEdit *le22 = w2->findChild<QLineEdit*>(QLatin1String("lineEdit2")); le22->setFocus(); QTRY_COMPARE(QApplication::focusWidget(), le22); // Going back should move focus back to le11 sw->setCurrentIndex(0); QTRY_COMPARE(QApplication::focusWidget(), le11); }
int main(int argc,char **argv) { QApplication app(argc,argv); QCoreApplication::setOrganizationName("Rabitsa"); QCoreApplication::setApplicationName("filters"); QApplication::setStyle(new QPlastiqueStyle); QSettings s; IoNetClient net( s.value("/ioserv/hostname","localhost").toString()); net.setCmode( #ifdef WIN32 false #else s.value("/ioserv/cmode",true).toBool() #endif ); QStackedWidget main; QColor cl; QPalette pal; cl.setRgb(90,132,201); pal.setColor(QPalette::Background,cl); main.setPalette(pal); QTranslator translator; translator.load("filters_"+QLocale::system().name(),":/translate"); app.installTranslator(&translator); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); mMainForm *mainForm = new mMainForm(net); main.addWidget(mainForm); main.setCurrentWidget(mainForm); if(QApplication::desktop()->size().width()>1366 && QApplication::desktop()->size().height()> 768) { main.resize(1366,768); main.show(); } else { main.showFullScreen(); } return app.exec(); }