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. Managing events of a QScxmlStateMachine
Forum Updated to NodeBB v4.3 + New Features

Managing events of a QScxmlStateMachine

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 513 Views
  • 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.
  • M Offline
    M Offline
    Max
    wrote on last edited by
    #1

    Hi!

    Here's my problem: the events sent by submitEvent("myTransition") are not executed immediately, but just after the client code and just before the application gives the hand to the user.
    The problem is I test the active state just after submitEvent("myTransition").

    I believe that the event sent by submitEvent("myTransition") is placed on the main event loop queue list and treated just before waiting a new user event.

    To solve this problem I run this command just after submitEvent():
    QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
    But the Qt documentation warns that it's not recommended to use it, so I'm looking for a another solution.

    I've found in the documentation page ScxmlStateMachine QML Type, at the end of the page, another use of submitEvent(event). The doc tells that this method Submits the SCXML event event to the internal or external event queue depending on the priority of the event..
    It looks interesting so I looked for elements for these event queues and how giving priority to an event, but I didn't find anything, even in the QScxmlEvent doc.

    So, can it be a solution to my problem? If yes, how to do this?

    Thanks!
    Max

    jsulmJ 1 Reply Last reply
    0
    • M Max

      Hi!

      Here's my problem: the events sent by submitEvent("myTransition") are not executed immediately, but just after the client code and just before the application gives the hand to the user.
      The problem is I test the active state just after submitEvent("myTransition").

      I believe that the event sent by submitEvent("myTransition") is placed on the main event loop queue list and treated just before waiting a new user event.

      To solve this problem I run this command just after submitEvent():
      QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
      But the Qt documentation warns that it's not recommended to use it, so I'm looking for a another solution.

      I've found in the documentation page ScxmlStateMachine QML Type, at the end of the page, another use of submitEvent(event). The doc tells that this method Submits the SCXML event event to the internal or external event queue depending on the priority of the event..
      It looks interesting so I looked for elements for these event queues and how giving priority to an event, but I didn't find anything, even in the QScxmlEvent doc.

      So, can it be a solution to my problem? If yes, how to do this?

      Thanks!
      Max

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Max said in Managing events of a QScxmlStateMachine:

      The problem is I test the active state just after submitEvent("myTransition").

      Why? This is not correct in an event driven application.
      What are you trying to achieve?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Max
        wrote on last edited by
        #3

        I have to test the active state to adapt the style sheet of a widget.

        jsulmJ 1 Reply Last reply
        0
        • M Max

          I have to test the active state to adapt the style sheet of a widget.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Max Usually you would react to a signal or event

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Max
            wrote on last edited by
            #5

            Hello!
            It's the case: when a QTextEdit is filled it sends a signal. In the corresponding slot I call a submitEvent() and then I test the state of the machine. If the machine is in a particular state, I modify the style of another widget before the hand is sent back to the user.
            But without the QApplication::processEvents() after the submitEvent() the state of the machine doesn't change immediately and the style of the widget is not set conveniently.

            jsulmJ 1 Reply Last reply
            0
            • M Max

              Hello!
              It's the case: when a QTextEdit is filled it sends a signal. In the corresponding slot I call a submitEvent() and then I test the state of the machine. If the machine is in a particular state, I modify the style of another widget before the hand is sent back to the user.
              But without the QApplication::processEvents() after the submitEvent() the state of the machine doesn't change immediately and the style of the widget is not set conveniently.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Max said in Managing events of a QScxmlStateMachine:

              If the machine is in a particular state, I modify the style of another widget before the hand is sent back to the user

              In an event driven application you would react on state machine change instead of posting an event and expecting it to take effect immediately. You should rethink your design.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • M Offline
                M Offline
                Max
                wrote on last edited by
                #7

                Ok, I understand.
                Thanks a lot!
                Max

                1 Reply Last reply
                0

                • Login

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