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. Create a QList of tasks
Qt 6.11 is out! See what's new in the release blog

Create a QList of tasks

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 1.6k Views 3 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.
  • D Offline
    D Offline
    DiaaQTdev
    wrote on last edited by
    #1

    Hello, i am new to QT, i am trying to create a list of tasks that is triggered by a Qtimer. but i am stuck in the phase of creating a model for my "Task" that each one is containing multiple lines of code to be executed and then wait for a timer to execute the next "task". how to implement this kind of tasks?

    any help in where to start or an example that illustrates my issue is welcomed!

    jsulmJ 1 Reply Last reply
    0
    • D DiaaQTdev

      Hello, i am new to QT, i am trying to create a list of tasks that is triggered by a Qtimer. but i am stuck in the phase of creating a model for my "Task" that each one is containing multiple lines of code to be executed and then wait for a timer to execute the next "task". how to implement this kind of tasks?

      any help in where to start or an example that illustrates my issue is welcomed!

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

      @DiaaQTdev said in Create a QList of tasks:

      that each one is containing multiple lines of code

      What code is that? From where does it come? From user? Please explain.

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

      1 Reply Last reply
      3
      • D Offline
        D Offline
        DiaaQTdev
        wrote on last edited by
        #3

        no there will be a loop that takes data from my Qtable and based on some conditions on that data, i will be adding lines of code( for example write to my serial port etc)

        Pl45m4P 1 Reply Last reply
        0
        • D DiaaQTdev

          no there will be a loop that takes data from my Qtable and based on some conditions on that data, i will be adding lines of code( for example write to my serial port etc)

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @DiaaQTdev

          Just write a function or functions and call them as needed?!

          @DiaaQTdev said in Create a QList of tasks:

          lines of code to be executed

          this is pretty much what a function does.

          Write conditions, create functions and connect them to your timer. Be careful that you dont block anything (if you dont want to).

          What is your "list of tasks"? It would help if you show what you have so far.

          Btw: Have you seen the SerialPort examples already?

          • https://doc.qt.io/qt-5/qtserialport-examples.html

          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          D 1 Reply Last reply
          0
          • Pl45m4P Pl45m4

            @DiaaQTdev

            Just write a function or functions and call them as needed?!

            @DiaaQTdev said in Create a QList of tasks:

            lines of code to be executed

            this is pretty much what a function does.

            Write conditions, create functions and connect them to your timer. Be careful that you dont block anything (if you dont want to).

            What is your "list of tasks"? It would help if you show what you have so far.

            Btw: Have you seen the SerialPort examples already?

            • https://doc.qt.io/qt-5/qtserialport-examples.html
            D Offline
            D Offline
            DiaaQTdev
            wrote on last edited by
            #5

            @Pl45m4 yes i did see examples for serial port. i am trying to queue my tasks before running it. calling functions will not help in this case. i am trying to prepare a scheduled queue with tasks prepared to be executed in time (using Qtimer).

            mrjjM jsulmJ J.HilkJ 3 Replies Last reply
            0
            • D DiaaQTdev

              @Pl45m4 yes i did see examples for serial port. i am trying to queue my tasks before running it. calling functions will not help in this case. i am trying to prepare a scheduled queue with tasks prepared to be executed in time (using Qtimer).

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @DiaaQTdev
              Hi
              It's a bit unclear what you want.

              You want to execute Tasks in order, meaning the next task will first start when the previous is finished?

              Or do you want to start a task at a certain point in time?

              1 Reply Last reply
              0
              • D DiaaQTdev

                @Pl45m4 yes i did see examples for serial port. i am trying to queue my tasks before running it. calling functions will not help in this case. i am trying to prepare a scheduled queue with tasks prepared to be executed in time (using Qtimer).

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

                @DiaaQTdev I really don't get what exactly the problem is.
                How to add a task to a QList?

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

                1 Reply Last reply
                0
                • D DiaaQTdev

                  @Pl45m4 yes i did see examples for serial port. i am trying to queue my tasks before running it. calling functions will not help in this case. i am trying to prepare a scheduled queue with tasks prepared to be executed in time (using Qtimer).

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @DiaaQTdev you could map your "tasks" to an enum and store the enums in a QList, and then simply decide, depending on the enum, what function you want to call.

                  Much more versatile and readable then for example storing function pointers in a list.


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  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