#include#include namespace sc = boost::statechart; struct MyStateMachine : sc::state_machine { }; struct MyInitialState : sc::simple_state { typedef sc::transition reactions; }; struct MyState1 : sc::simple_state { typedef sc::transition reactions; }; struct MyState2 : sc::simple_state { };
#includeIn the above example, the state_type is used to keep track of the current state of the line edit widget - either enabled or disabled, depending on whether there is any text entered in the field.#include class MyWidget : public QWidget { public: MyWidget(QWidget *parent = nullptr); private: QLineEdit *mLineEdit; }; MyWidget::MyWidget(QWidget *parent) : QWidget(parent) , mLineEdit(new QLineEdit(this)) { connect(mLineEdit, &QLineEdit::textChanged, this, &MyWidget::onTextChanged); } void MyWidget::onTextChanged(const QString &text) { if (!text.isEmpty()) { mLineEdit->setEnabled(false); } else { mLineEdit->setEnabled(true); } }