Create a QList of tasks
-
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!
-
@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.
-
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?
-
@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).
-
@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?
-
@DiaaQTdev I really don't get what exactly the problem is.
How to add a task to a QList? -
@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.