本文整理汇总了C++中QStateMachine::start方法的典型用法代码示例。如果您正苦于以下问题:C++ QStateMachine::start方法的具体用法?C++ QStateMachine::start怎么用?C++ QStateMachine::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStateMachine
的用法示例。
在下文中一共展示了QStateMachine::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupItemAnimations
void DiscountPage::setupItemAnimations()
{
QState *smallState = new QState();
QState *bigState = new QState();
for (int i = 0; i < this->m_itemList.size(); i++) {
smallState->assignProperty(this->m_itemList[i],"scale", 0);
bigState->assignProperty(this->m_itemList[i],"scale",1);
}
QSequentialAnimationGroup *showItemGroup = new QSequentialAnimationGroup(this);
for (int i = 0; i < this->m_itemList.size(); i++) {
QPropertyAnimation *anim = new QPropertyAnimation(this->m_itemList[i], "scale", this);
anim->setDuration(300);
anim->setEasingCurve(QEasingCurve::OutBack);
showItemGroup->addAnimation(anim);
}
QSignalTransition *trans = smallState->addTransition(this, SIGNAL(start()), bigState);
trans->addAnimation(showItemGroup);
connect(showItemGroup,SIGNAL(finished()),this,SLOT(startSelect()));
trans = bigState->addTransition(this,SIGNAL(quitPage()),smallState);
connect(smallState,SIGNAL(entered()),this,SLOT(closeSelect()));
QStateMachine *states = new QStateMachine(this);
states->addState(smallState);
states->addState(bigState);
states->setInitialState(smallState);
states->start();
}
示例2: testLoadBackupRestoreStateOnEntryExit
void HomeScreenStatePluginTest::testLoadBackupRestoreStateOnEntryExit()
{
HbInstance::instance();
HbMainWindow mainWindow;
mainWindow.show();
QCoreApplication::sendPostedEvents();
QStateMachine *sm = new QStateMachine;
HsBackupRestoreState *brs = new HsBackupRestoreState;
sm->addState(brs);
sm->setInitialState(brs);
QFinalState *fs = new QFinalState;
sm->addState(fs);
brs->addTransition(this, SIGNAL(finishStateMachine()), fs);
sm->start();
QCoreApplication::sendPostedEvents();
emit finishStateMachine();
sm->stop();
// main window deleted -> HsGui must be deleted also
delete HsGui::takeInstance();
delete sm;
}
示例3: initShowHideAnimation
void DockPanel::initShowHideAnimation()
{
QStateMachine * machine = new QStateMachine(this);
QState * showState = new QState(machine);
showState->assignProperty(this,"y", 0);
QState * hideState = new QState(machine);
//y should change with DockMode changed
connect(this, &DockPanel::startHide, [=]{
hideState->assignProperty(this,"y", m_dockModeData->getDockHeight());
});
machine->setInitialState(showState);
QPropertyAnimation *showAnimation = new QPropertyAnimation(this, "y");
showAnimation->setDuration(SHOW_ANIMATION_DURATION);
showAnimation->setEasingCurve(SHOW_EASINGCURVE);
connect(showAnimation,&QPropertyAnimation::finished,this,&DockPanel::onShowPanelFinished);
QPropertyAnimation *hideAnimation = new QPropertyAnimation(this, "y");
hideAnimation->setDuration(HIDE_ANIMATION_DURATION);
hideAnimation->setEasingCurve(HIDE_EASINGCURVE);
connect(hideAnimation,&QPropertyAnimation::finished,this,&DockPanel::onHidePanelFinished);
QSignalTransition *st = showState->addTransition(this,SIGNAL(startHide()), hideState);
st->addAnimation(hideAnimation);
QSignalTransition *ht = hideState->addTransition(this,SIGNAL(startShow()),showState);
ht->addAnimation(showAnimation);
machine->start();
}
示例4: setupStateMachine
void MainWindow::setupStateMachine()
{
// set title bar text
this->setWindowTitle(QString("Excape From Estes"));
// create the state machine object and its states
QStateMachine *machine = new QStateMachine(this);
QState *s1 = new QState();
QState *s2 = new QState();
QState *s3 = new QState();
// assign an event for every state
s1->assignProperty(ui->label, "text", readFile("intro.txt"));
s2->assignProperty(ui->label, "text", "In state s2");
s3->assignProperty(ui->label, "text", "In state s3");
// set up a trigger to end every state
s1->addTransition(this, SIGNAL(one()), s2);
s2->addTransition(this, SIGNAL(two()), s3);
s3->addTransition(this->ui->pushButton, SIGNAL(clicked()), s1);
// add the states to the state machine and set a starting state
machine->addState(s1);
machine->addState(s2);
machine->addState(s3);
machine->setInitialState(s1);
// enable the machine and print out a message to show that we are done
machine->start();
qDebug() << "State Machine Created";
}
示例5: main
//! [4]
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QStateMachine machine;
QState *group = new QState(QState::ParallelStates);
group->setObjectName("group");
//! [4]
//! [5]
Pinger *pinger = new Pinger(group);
pinger->setObjectName("pinger");
pinger->addTransition(new PongTransition());
QState *ponger = new QState(group);
ponger->setObjectName("ponger");
ponger->addTransition(new PingTransition());
//! [5]
//! [6]
machine.addState(group);
machine.setInitialState(group);
machine.start();
return app.exec();
}
示例6: main
int main(int argc, char* argv[ ])
{
QApplication app(argc, argv);
QPushButton button("State Machine");
QPushButton quitButton("Quit");
QPushButton interruptButton("interrupt");
QStateMachine machine;
QState *s1 = new QState(&machine);
QState *s11 = new QState(s1);
QState *s12 = new QState(s1);
QState *s13 = new QState(s1);
s1->setInitialState(s11);
s11->assignProperty(&button, "geometry", QRect(100, 100, 100, 50));
s12->assignProperty(&button, "geometry", QRect(300, 100, 100, 50));
s13->assignProperty(&button, "geometry", QRect(200, 200, 100, 50));
QSignalTransition *transition1 = s11->addTransition(&button,
SIGNAL(clicked()), s12);
QSignalTransition *transition2 = s12->addTransition(&button,
SIGNAL(clicked()), s13);
QSignalTransition *transition3 = s13->addTransition(&button,
SIGNAL(clicked()), s11);
QPropertyAnimation *animation = new QPropertyAnimation(&button, "geometry");
transition1->addAnimation(animation);
transition2->addAnimation(animation);
transition3->addAnimation(animation);
QObject::connect(s13, SIGNAL(entered()), &button, SLOT(showMinimized()));
QFinalState *s2 = new QFinalState(&machine);
s1->addTransition(&quitButton, SIGNAL(clicked()), s2);
QObject::connect(&machine, SIGNAL(finished()), qApp, SLOT(quit()));
QHistoryState *s1h = new QHistoryState(s1);
QState *s3 = new QState(&machine);
QMessageBox mbox;
mbox.addButton(QMessageBox::Ok);
mbox.setText("Interrupted!");
mbox.setIcon(QMessageBox::Information);
QObject::connect(s3, SIGNAL(entered()), &mbox, SLOT(exec()));
s3->addTransition(s1h);
s1->addTransition(&interruptButton, SIGNAL(clicked()), s3);
machine.setInitialState(s1);
machine.start();
button.show();
quitButton.move(300, 300);
quitButton.show();
interruptButton.show();
return app.exec();
}
示例7: 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();
}
示例8: createArrangeCollection
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void MenuStatesTest::createArrangeCollection()
{
#ifdef Q_OS_SYMBIAN
User::ResetInactivityTime();//it should help for Viewserver11 panic
#ifdef UT_MEMORY_CHECK
__UHEAP_MARK;
#endif//UT_MEMORY_CHECK
#endif//Q_OS_SYMBIAN
{
HsMenuViewBuilder builder;
HsMenuModeWrapper menuMode;
HsMainWindowMock mainWindow;
QStateMachine *machine = new QStateMachine(0);
const QString collectionName("testCollection" +
QDateTime::currentDateTime().
toString("ddmmyyyy_hh_mm_ss_zzz"));
const int collectionId = HsMenuService::createCollection(collectionName);
HsCollectionState *collectionState =
new HsCollectionState(builder, menuMode, mainWindow, machine);
collectionState->mCollectionId = collectionId;
machine->setInitialState(collectionState);
AddToHomeScreenMockState *mockState = new AddToHomeScreenMockState(machine);
// create a transition to the new child state which will be triggered by
// an event with specified operation type
HsMenuEventTransition *transition = new HsMenuEventTransition(
HsMenuEvent::ArrangeCollection, collectionState, mockState);
collectionState->addTransition(transition);
machine->start();
qApp->sendPostedEvents();
collectionState->createArrangeCollection();
qApp->sendPostedEvents();
QVERIFY(mockState->enteredValue());
qApp->removePostedEvents(0);
machine->stop();
delete machine;
}
#ifdef Q_OS_SYMBIAN
#ifdef UT_MEMORY_CHECK
__UHEAP_MARKEND;
#endif//UT_MEMORY_CHECK
#endif//Q_OS_SYMBIAN
}
示例9: Window
Window(QWidget *parent = 0)
: QWidget(parent)
{
QPushButton *button = new QPushButton(this);
button->setGeometry(QRect(100, 100, 100, 100));
//! [0]
//! [1]
QStateMachine *machine = new QStateMachine(this);
QState *s1 = new QState();
s1->assignProperty(button, "text", "Outside");
QState *s2 = new QState();
s2->assignProperty(button, "text", "Inside");
//! [1]
//! [2]
QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter);
enterTransition->setTargetState(s2);
s1->addTransition(enterTransition);
//! [2]
//! [3]
QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave);
leaveTransition->setTargetState(s1);
s2->addTransition(leaveTransition);
//! [3]
//! [4]
QState *s3 = new QState();
s3->assignProperty(button, "text", "Pressing...");
QEventTransition *pressTransition = new QEventTransition(button, QEvent::MouseButtonPress);
pressTransition->setTargetState(s3);
s2->addTransition(pressTransition);
QEventTransition *releaseTransition = new QEventTransition(button, QEvent::MouseButtonRelease);
releaseTransition->setTargetState(s2);
s3->addTransition(releaseTransition);
//! [4]
//! [5]
machine->addState(s1);
machine->addState(s2);
machine->addState(s3);
machine->setInitialState(s1);
machine->start();
}
示例10: main
int main(int argv, char **args)
{
QApplication app(argv, args);
QLabel *label = new QLabel;
//![0]
QStateMachine machine;
QState *s1 = new QState();
QState *s2 = new QState();
QState *s3 = new QState();
//![0]
//![4]
s1->assignProperty(label, "text", "In state s1");
s2->assignProperty(label, "text", "In state s2");
s3->assignProperty(label, "text", "In state s3");
//![4]
//![5]
QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized()));
QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized()));
//![5]
//![1]
s1->addTransition(button, SIGNAL(clicked()), s2);
s2->addTransition(button, SIGNAL(clicked()), s3);
s3->addTransition(button, SIGNAL(clicked()), s1);
//![1]
//![2]
machine.addState(s1);
machine.addState(s2);
machine.addState(s3);
machine.setInitialState(s1);
//![2]
//![3]
machine.start();
//![3]
label->show();
return app.exec();
}
示例11: main
//! [0]
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QPushButton button;
QStateMachine machine;
//! [0]
//! [1]
QState *off = new QState();
off->assignProperty(&button, "text", "Off");
off->setObjectName("off");
QState *on = new QState();
on->setObjectName("on");
on->assignProperty(&button, "text", "On");
//! [1]
//! [2]
off->addTransition(&button, SIGNAL(clicked()), on);
on->addTransition(&button, SIGNAL(clicked()), off);
//! [2]
//! [3]
machine.addState(off);
machine.addState(on);
//! [3]
//! [4]
machine.setInitialState(off);
machine.start();
//! [4]
//! [5]
#if defined(Q_OS_SYMBIAN)
button.showMaximized();
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
button.show();
#else
button.resize(100, 50);
button.show();
#endif
return app.exec();
}
示例12: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
// Загружаем интерфейс пользователя из формы и устанавливаем действия в меню
ui->setupUi(this);
connect(ui->action_start, SIGNAL(triggered()), ui->startButton, SLOT(click()));
connect(ui->action_exit, SIGNAL(triggered()), this, SLOT(close()));
connect(ui->action_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(ui->action_help, SIGNAL(triggered()), this, SLOT(showHelp()));
connect(ui->action_about, SIGNAL(triggered()), this, SLOT(showAbout()));
connect(ui->action_tech, SIGNAL(triggered()), this, SLOT(showTz()));
// Заводим машину состояний
QStateMachine *animation = new QStateMachine(this);
QState *idle = new QState();
QState *animating = new QState();
animating->assignProperty(ui->startButton,"text", tr("&Стоп"));
animating->assignProperty(ui->startButton,"icon", QIcon(":/icons/control-stop-square.png"));
animating->assignProperty(ui->action_start,"text",tr("О&становить анимацию"));
animating->assignProperty(ui->action_start,"icon", QIcon(":/icons/control-stop-square.png"));
idle->assignProperty(ui->startButton,"text", tr("Пу&ск"));
idle->assignProperty(ui->startButton,"icon", QIcon(":/icons/control.png"));
idle->assignProperty(ui->action_start,"text",tr("Запу&стить анимацию"));
idle->assignProperty(ui->action_start,"icon", QIcon(":/icons/control.png"));
QSignalTransition *startTransition = new QSignalTransition(ui->startButton, SIGNAL(clicked()), idle);
startTransition->setTargetState(animating);
QSignalTransition *stopTransition = new QSignalTransition(ui->startButton, SIGNAL(clicked()), animating);
stopTransition->setTargetState(idle);
QSignalTransition *doneTransition = new QSignalTransition(ui->widget, SIGNAL(animationStopped()), animating);
doneTransition->setTargetState(idle);
connect(startTransition, SIGNAL(triggered()), ui->widget, SLOT(startAnimation()));
connect(stopTransition, SIGNAL(triggered()), ui->widget, SLOT(stopAnimation()));
idle->addTransition(startTransition);
animating->addTransition(stopTransition);
animating->addTransition(doneTransition);
animation->addState(idle);
animation->addState(animating);
animation->setInitialState(idle);
animation->start();
// В Linux мячик иногда сразу не отображается...
ui->widget->updateGL();
}
示例13: initStateMachine
void ZoneDeDessin::initStateMachine() {
QStateMachine * mac = new QStateMachine( );
QState *s1 = new QState(); //mouse up
QState *s2 = new QState(); //mouse down
s2->assignProperty(this, "text", "tja");
mac->addState(s1);
mac->addState(s2);
mac->setInitialState(s1);
mac->start();
addTrans(s1, s2, this, QEvent::MouseButtonPress, Qt::LeftButton);
addTrans(s2, s2, this, QEvent::MouseMove, Qt::NoButton);
addTrans(s2, s1, this, QEvent::MouseButtonRelease, Qt::LeftButton);
connect(s1, SIGNAL(exited()), this, SLOT(startDraw())); // leave mouseup
connect(s2, SIGNAL(entered()), this, SLOT(drawing())); // enter mousedown
connect(s1, SIGNAL(entered()), this, SLOT(endDraw())); // enter mouseup
}
示例14: init
void TMainWind::init()
{
setCentralWidget(m_canvas = new TCanvas);
QLabel* statusLabel = new QLabel;
statusBar()->addPermanentWidget(statusLabel);
QStateMachine* machine = new QStateMachine(this);
QState* creation = new QState;
QState* bending = new QState; // transformation
QState* painting = new QState;
QState* extrusion = new QState;
creation->assignProperty(m_canvas, "mode", TCanvas::Creation);
creation->assignProperty(statusLabel, "text", tr("Mode: Creation"));
creation->addTransition(m_canvas, SIGNAL(creationFinished()), painting);
bending->assignProperty(m_canvas, "mode", TCanvas::Bending);
bending->assignProperty(statusLabel, "text", tr("Mode: Bending"));
bending->addTransition(m_canvas, SIGNAL(bendingFinished()), painting);
painting->assignProperty(m_canvas, "mode", TCanvas::Painting);
painting->assignProperty(statusLabel, "text", tr("Mode: Painting"));
painting->addTransition(m_canvas, SIGNAL(toEdit()), extrusion);
extrusion->assignProperty(m_canvas, "mode", TCanvas::Extrusion);
extrusion->assignProperty(statusLabel, "text", tr("Mode: Extrusion"));
extrusion->addTransition(m_canvas, SIGNAL(extrusionFinished()), painting);
bending->addTransition(m_canvas, SIGNAL(restart()), creation);
painting->addTransition(m_canvas, SIGNAL(restart()), creation);
extrusion->addTransition(m_canvas, SIGNAL(restart()), creation);
machine->addState(creation);
machine->addState(bending);
machine->addState(painting);
machine->addState(extrusion);
machine->setInitialState(creation);
machine->start();
}
示例15: main
//! [0]
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QPushButton button;
QStateMachine machine;
//! [0]
//! [1]
QState *off = new QState();
off->assignProperty(&button, "text", "Off");
off->setObjectName("off");
QState *on = new QState();
on->setObjectName("on");
on->assignProperty(&button, "text", "On");
//! [1]
//! [2]
off->addTransition(&button, SIGNAL(clicked()), on);
on->addTransition(&button, SIGNAL(clicked()), off);
//! [2]
//! [3]
machine.addState(off);
machine.addState(on);
//! [3]
//! [4]
machine.setInitialState(off);
machine.start();
//! [4]
//! [5]
button.resize(100, 50);
button.show();
return app.exec();
}