本文整理汇总了C++中QStackedWidget::show方法的典型用法代码示例。如果您正苦于以下问题:C++ QStackedWidget::show方法的具体用法?C++ QStackedWidget::show怎么用?C++ QStackedWidget::show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget::show方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dynamicPages
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);
}
示例2: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
std::random_device rd;
random_engine gen(rd());
int imageSize = 300;
QList<QImage> images;
for (int n = 0; n < 28; ++n) images << randomImage(imageSize, gen);
std::uniform_int_distribution<> dImage(0, images.size()-1);
QStackedWidget display;
QPushButton ready("I'm Ready!");
QLabel label, labelHidden;
display.addWidget(&ready);
display.addWidget(&label);
display.addWidget(&labelHidden);
QTimer splashTimer;
QStateMachine machine;
QState s1(&machine), s2(&machine), s3(&machine), s4(&machine);
splashTimer.setSingleShot(true);
QObject::connect(&s1, &QState::entered, [&]{
display.setCurrentWidget(&ready);
ready.setDefault(true);
ready.setFocus();
});
s1.addTransition(&ready, "clicked()", &s2);
QObject::connect(&s2, &QState::entered, [&]{
label.setPixmap(QPixmap::fromImage(images.at(dImage(gen))));
display.setCurrentWidget(&label);
splashTimer.start(250 + std::uniform_int_distribution<>(1500, 3000)(gen));
});
s2.addTransition(&splashTimer, "timeout()", &s3);
QObject::connect(&s3, &QState::entered, [&]{
display.setCurrentWidget(&labelHidden);
splashTimer.start(2000);
});
s3.addTransition(&splashTimer, "timeout()", &s4);
QObject::connect(&s4, &QState::entered, [&]{
display.setCurrentWidget(&label);
splashTimer.start(3000);
});
s4.addTransition(&splashTimer, "timeout()", &s1);
machine.setInitialState(&s1);
machine.start();
display.show();
return a.exec();
}
示例3: main
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();
}