当前位置: 首页>>代码示例>>C++>>正文


C++ QStackedWidget::setCurrentWidget方法代码示例

本文整理汇总了C++中QStackedWidget::setCurrentWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QStackedWidget::setCurrentWidget方法的具体用法?C++ QStackedWidget::setCurrentWidget怎么用?C++ QStackedWidget::setCurrentWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStackedWidget的用法示例。


在下文中一共展示了QStackedWidget::setCurrentWidget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:55,代码来源:main.cpp

示例2: main

int main( int argc, char *argv[] )
{

    QApplication a( argc, argv );

    QMainWindow mainWindow;

    HGRSVM svm = HGRSVM();
    svm.train( 100 );

    QStackedWidget *stackedWidget = new QStackedWidget;

    MyMainWindow *myMainWindow = new MyMainWindow( stackedWidget );

    stackedWidget->addWidget( myMainWindow );
    stackedWidget->setCurrentWidget( myMainWindow );

    mainWindow.setCentralWidget(stackedWidget);
    mainWindow.setWindowTitle( "Hand gesture recognition for ArDrone" );
    mainWindow.resize(950, 500);
    mainWindow.show();

    thread th1( runArdrone );


    int status = a.exec();



    order = 1;
 th1.join();

    return status;
}
开发者ID:SirYacc,项目名称:ter,代码行数:34,代码来源:main.cpp

示例3: if

void
InsertPageCommand::execute()
{
    KFormDesigner::Container *container = m_form->objectTree()->lookup(m_containername)->container();
    QWidget *parent = m_form->objectTree()->lookup(m_parentname)->widget();
    if (m_name.isEmpty()) {
        m_name = container->form()->objectTree()->generateUniqueName(
                     container->form()->library()->displayName("QWidget").toLatin1(),
                     /*!numberSuffixRequired*/false);
    }

    QWidget *page = container->form()->library()->createWidget(
        "QWidget", parent, m_name.toLatin1(), container);
    page->setAutoFillBackground(true);
//    page->setPaletteBackgroundColor(Qt::red);
    KFormDesigner::ObjectTreeItem *item = container->form()->objectTree()->lookup(m_name);

    QByteArray classname = parent->metaObject()->className();
    if (classname == "KFDTabWidget") {
        TabWidgetBase *tab = dynamic_cast<TabWidgetBase*>(parent);
        QString n = i18n("Page %1", tab->count() + 1);
        tab->addTab(page, n);
        tab->setCurrentWidget(page);
        item->addModifiedProperty("title", n);
    } else if (classname == "QStackedWidget" || /* compat */ classname == "QWidgetStack") {
        QStackedWidget *stack = dynamic_cast<QStackedWidget*>(parent);
        stack->addWidget(page);
        stack->setCurrentWidget(page);
        item->addModifiedProperty("stackIndex", stack->indexOf(page));
    }
}
开发者ID:JeremiasE,项目名称:KFormula,代码行数:31,代码来源:containerfactory.cpp

示例4: 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();
}
开发者ID:vanessaorgua,项目名称:Linovitsa,代码行数:49,代码来源:main.cpp

示例5: recreate_instruments_widget_from_state

static void recreate_instruments_widget_from_state(vector_t *state){
  QStackedWidget* tabs = instruments_widget->tabs;

  while(tabs->count()>0)
    tabs->removeWidget(tabs->currentWidget());

  //vector_t *names = (vector_t*)state->elements[0];
  vector_t *pages = (vector_t*)state->elements[0];

  for(int i=pages->num_elements-1; i>=0; i--){
    QWidget *page = (QWidget*)pages->elements[i];
    tabs->insertWidget(0,page);//,(const char*)names->elements[i]);
  }

  tabs->setCurrentWidget((QWidget*)state->elements[1]);
}
开发者ID:onukore,项目名称:radium,代码行数:16,代码来源:undo_instruments_widget.cpp


注:本文中的QStackedWidget::setCurrentWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。