Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Easy way to "reuse" transitions from State Machine Framework
Forum Updated to NodeBB v4.3 + New Features

Easy way to "reuse" transitions from State Machine Framework

Scheduled Pinned Locked Moved Unsolved General and Desktop
state machinestatemachineframework
2 Posts 2 Posters 629 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arthur Araruna
    wrote on last edited by
    #1

    Hello,

    I'm designing an application in which I make use of the SMF to help synchronize some of the widgets depending on user interaction.

    The problem I have is that there are some situations in which, for a one same action taken by the user (in a particular case, a KeyPress event), I must transition to a particular state A if I'm in one of the {B,C,D,F} states (state names for example purpose).

    So, what I have to do is add, for each of the states in {B,C,D,F}, one QEventTransition of type QEvent::KeyPress, all of them having the same destination. But as the states claim ownership of transitions, I cannot new up a single QEventTransition and pass it to those states, forcing me to replicate the code several times.

    Is this really the way? Isn't there any way to reuse a transition, or even "clone" one to avoid so much retyping?

    QEventTransition *t_maybeNewEntry = Q_NULLPTR;
    t_maybeNewEntry = new QEventTransition(
                    mainWindow.ui->lineEditOutput,
                    QEvent::KeyPress
                    );
    t_maybeNewEntry->setTargetState(s_hasEntry);
    //...
    t_maybeNewEntry = new QEventTransition(
                    mainWindow.ui->lineEditOutput,
                    QEvent::KeyPress
                    );
    t_maybeNewEntry->setTargetState(s_hasEntry);
    //...
    t_maybeNewEntry = new QEventTransition(
                    mainWindow.ui->lineEditOutput,
                    QEvent::KeyPress
                    );
    t_maybeNewEntry->setTargetState(s_hasEntry);
    //... ... ...
    

    Thank you.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MrShawn
      wrote on last edited by MrShawn
      #2

      Have a look at the State Machine Framework documentation here.

      Basically make one state with your defined transition, and create your other states accordingly with the parent state that has your single transition defined.

      Good luck.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved