Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Best way make this sequence based to user choice
Forum Updated to NodeBB v4.3 + New Features

Best way make this sequence based to user choice

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 934 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.
  • deleted57D Offline
    deleted57D Offline
    deleted57
    wrote on last edited by
    #1

    Hi all
    In my app develop using QML I need to start a sequence of steps based to user choice. For example create a new document. At first check for current one is modified, in case of yes ask to user if he want to save. If yes open file save dialog and check if the name document name inserted already exist. If yes ask if overrite. If yes overrtie and return to first step where new document is created. If no return to previous step for ask of a new file document name (and so on). This is one of tha classic sequence. Now make this steps using Qt C++ is very easy since for each step a modal messagebox stop the execution of the code waiting for user choice. However, since QML is all asyncronous is not possible to stop the executon in a specific point waitint for a reply than code for make this sequence can become really complex and redundant.
    What is the bast way to make this sequence in QML in an easy way? (if exist...)
    Thank you

    E 1 Reply Last reply
    0
    • deleted57D deleted57

      Hi all
      In my app develop using QML I need to start a sequence of steps based to user choice. For example create a new document. At first check for current one is modified, in case of yes ask to user if he want to save. If yes open file save dialog and check if the name document name inserted already exist. If yes ask if overrite. If yes overrtie and return to first step where new document is created. If no return to previous step for ask of a new file document name (and so on). This is one of tha classic sequence. Now make this steps using Qt C++ is very easy since for each step a modal messagebox stop the execution of the code waiting for user choice. However, since QML is all asyncronous is not possible to stop the executon in a specific point waitint for a reply than code for make this sequence can become really complex and redundant.
      What is the bast way to make this sequence in QML in an easy way? (if exist...)
      Thank you

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Suppaman I did some complex dialog sequences with StateMachine. I needed to take account of TCP connection to another device which had to be established if not ready already, success and failure of the connection at any moment, end user cancelling or accepting the action etc. It works when you learn how to use StateMachine. Was it easy? No. Was it the best way? I don't know. I migrated to StateMachine in an early phase because sequential actions didn't seem to be enough for the needs, so I don't even know if it had been possible without state machine. But in the end it might be easier to use StateMachine than to make one change after another to an ad hoc sequential code. A state machine will be robust if you design the states properly and after you have learned how to use and implement a state machine. Until that it will be painful.

      1 Reply Last reply
      0
      • deleted57D Offline
        deleted57D Offline
        deleted57
        wrote on last edited by
        #3

        @Eeli-K thank you for your contribute. I came to the same conclusion about use of StateMachine too and I was making some experiment with it. It can work but the doubt I have is how to "manage" the switch back to the previous state from last state once user make a choice. I mean, following my example if the user select to don't overrite the existing file document the state machine have to move back to the previous state of the sequence where it again ask the name of the file document to save. On the contrary if the user decide to overrite the document the state machine have to move back the the first state of the sequence (where new document is created).
        How did you manage this "stack" of states?

        E 1 Reply Last reply
        0
        • deleted57D deleted57

          @Eeli-K thank you for your contribute. I came to the same conclusion about use of StateMachine too and I was making some experiment with it. It can work but the doubt I have is how to "manage" the switch back to the previous state from last state once user make a choice. I mean, following my example if the user select to don't overrite the existing file document the state machine have to move back to the previous state of the sequence where it again ask the name of the file document to save. On the contrary if the user decide to overrite the document the state machine have to move back the the first state of the sequence (where new document is created).
          How did you manage this "stack" of states?

          E Offline
          E Offline
          Eeli K
          wrote on last edited by
          #4

          @Suppaman It's been a long time since I made it, I don't remember everything. But it should be possible with normal means. Mostly it's that onEntered of a state makes changes to the visible state of a dialog, including opening and closing it, and SignalTransition receives signals from dialogs or when the user does something. If you can write a self-contained minimal example with the problem identified I could look at it further.

          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