qstatemachine

Emitting signals from class, if transition in QStateMachine was successful

旧巷老猫 提交于 2020-01-01 18:55:07
问题 My problem is the following: I need to create class, which contains QStateMachine instance. This class should have slots through which you could "ask" state machine to make transition to another state. And if transition was successful, my class should emit signal about it. How would I implement this? Class should have ability to emit certain signals according to certain slot invoke. Here is a small example of class: class MyClass : public QObject { Q_OBJECT public: explicit MyClass(QObject

Transitioning between menu screens with QStateMachine

泄露秘密 提交于 2019-12-11 23:42:06
问题 I am considering transitioning between menu screens in a game by using QStateMachine . However, I'm unsure how to kick off some code (e.g. show() a QWidget ) upon a transition between states occurring. I can do it quite easily with plain old signals (see commented out code), but I figure that I could probably do some fancy animation upon switching screens using transitions. Here's my code: Edit: updated as per Koying's suggestion. ApplicationWindow.h : #include <QtGui> #include <QStateMachine

How can I terminate QStateMachine when QDialog is closed?

此生再无相见时 提交于 2019-12-11 03:37:29
问题 I have a QDialog and QStateMachine. This loop terminates when the all aplication is closed but i want to terminate loop when Qdialog is closed. How can i do that? QStateMachine sm; QState s1(&sm), s2(&sm); sm.setInitialState(&s1); QEventTransition transition(dialog, QEvent::Close); s2.addTransition(&transition); QEventLoop loop; QObject::connect(&s2, &QState::entered, &loop, &QEventLoop::quit); sm.start(); dialog->show(); loop.exec(); 回答1: Use QFinalState class for this. At docs example shown

How to design a state machine in face of non-blocking I/O?

▼魔方 西西 提交于 2019-12-06 08:48:05
问题 I'm using Qt framework which has by default non-blocking I/O to develop an application navigating through several web pages (online stores) and carrying out different actions on these pages. I'm "mapping" specific web page to a state machine which I use to navigate through this page. This state machine has these transitions; Connect, LogIn, Query, LogOut, Disconnect and these states; Start, Connecting, Connected, LoggingIn, LoggedIn, Querying, QueryDone, LoggingOut, LoggedOut, Disconnecting,

Emitting signals from class, if transition in QStateMachine was successful

北城余情 提交于 2019-12-04 16:43:00
My problem is the following: I need to create class, which contains QStateMachine instance. This class should have slots through which you could "ask" state machine to make transition to another state. And if transition was successful, my class should emit signal about it. How would I implement this? Class should have ability to emit certain signals according to certain slot invoke. Here is a small example of class: class MyClass : public QObject { Q_OBJECT public: explicit MyClass(QObject *parent = 0) { mStateMachine = new QStateMachine(this); QState *s1 = new QState(mStateMachine); QState

How to design a state machine in face of non-blocking I/O?

别等时光非礼了梦想. 提交于 2019-12-04 13:16:27
I'm using Qt framework which has by default non-blocking I/O to develop an application navigating through several web pages (online stores) and carrying out different actions on these pages. I'm "mapping" specific web page to a state machine which I use to navigate through this page. This state machine has these transitions; Connect, LogIn, Query, LogOut, Disconnect and these states; Start, Connecting, Connected, LoggingIn, LoggedIn, Querying, QueryDone, LoggingOut, LoggedOut, Disconnecting, Disconnected Transitions from *ing to *ed states ( Connecting->Connected ), are due to LoadFinished

How to get this Qt state machine to work?

不羁的心 提交于 2019-12-03 16:29:27
问题 I have two widgets that can be checked, and a numeric entry field that should contain a value greater than zero. Whenever both widgets have been checked, and the numeric entry field contains a value greater than zero, a button should be enabled. I am struggling with defining a proper state machine for this situation. So far I have the following: QStateMachine *machine = new QStateMachine(this); QState *buttonDisabled = new QState(QState::ParallelStates); buttonDisabled->assignProperty(ui_-

How to get this Qt state machine to work?

橙三吉。 提交于 2019-12-03 05:35:29
I have two widgets that can be checked, and a numeric entry field that should contain a value greater than zero. Whenever both widgets have been checked, and the numeric entry field contains a value greater than zero, a button should be enabled. I am struggling with defining a proper state machine for this situation. So far I have the following: QStateMachine *machine = new QStateMachine(this); QState *buttonDisabled = new QState(QState::ParallelStates); buttonDisabled->assignProperty(ui_->button, "enabled", false); QState *a = new QState(buttonDisabled); QState *aUnchecked = new QState(a);

QStateMachine - QMouseEvent

谁说我不能喝 提交于 2019-12-02 16:23:40
问题 In another question you tell me to use QStateMachine. I'm new to Qt and it's the first time i use the objects so I make a lot of logical mistake, so using QStateMachine it's a big problem... It's the only way to do thath ? I try to explain my program: I want to create a card's game and in the previous version I've used an old graphics library with this sequence of commands: -> print cards on the scene -> wait for a mouse input (with a do-while) -> if(isMouseClick(WM_LBUTTONDOWN)) -> if(mouse

QStateMachine - QMouseEvent

孤街醉人 提交于 2019-12-02 08:25:47
In another question you tell me to use QStateMachine. I'm new to Qt and it's the first time i use the objects so I make a lot of logical mistake, so using QStateMachine it's a big problem... It's the only way to do thath ? I try to explain my program: I want to create a card's game and in the previous version I've used an old graphics library with this sequence of commands: -> print cards on the scene -> wait for a mouse input (with a do-while) -> if(isMouseClick(WM_LBUTTONDOWN)) -> if(mouse position is on the first card) -> select that card. So i wish to do the same thing with QGraphics. In