Your "i < ui->spinBox->value()" will call that function on every single iteration. That's an allocation(that's if the compiler manages to figure out what Qt does and apply return value optimization) to parse the String and the parsing itself. You can do this with templated containers and there is still no guarantee that the compiler will optimize that function away. Just put a "const int length = ui->spinBox->value()" before the loop and use the const inside...
Thanks for the video. I have problem of applying QFutureWatcher for a single long function. In the documentation I saw I could do like "QFuture future = QtConcurrent::run(...);" But the problem is same documentation says I cannot use QtConcurrent::run() for progress reporting. Do you have any idea how to handle that?
Signals and slots... I cover this in my QT design patterns course, but basically you're going to want to create a class and then use concurrent to execute a method in the class
@@VoidRealms Thank you for the reply. But even I used signal/slot I would be in a difficult situation to calculate the progress. I should manually calculate how much progress has happened and emit a signal, right? I found out it is impossible to progress indication when it is single method to be executed. Here is a part of a comment I found in here. forum.qt.io/topic/31584/qfuture-and-qfuturewatcher-to-update-progress/5 "Since in this case, only a single function is called in a separate thread, QtConcurrent simply doesn't know enough to give you progress indication. What you want is a structure where you process a lot of objects using a Map or Filter method." Am I correct? Your videos are really helpful. Thanks a lot.
@@hareendraperera7562 you would create and track the progress inside of the class you would run... QT concurrent would have no concept of the task you're trying to perform it's going to just shove whatever you give it into a qthreadpool in the background, Make a class with a function called run inside that function you would create some steps run some code track the progress and a emit a signal
Your "i < ui->spinBox->value()" will call that function on every single iteration. That's an allocation(that's if the compiler manages to figure out what Qt does and apply return value optimization) to parse the String and the parsing itself.
You can do this with templated containers and there is still no guarantee that the compiler will optimize that function away.
Just put a "const int length = ui->spinBox->value()" before the loop and use the const inside...
How are you able to set progress of progressbar? When I'm trying to do so in my example, my progressbar is set to indefinite mode (Qt 6.4.1)
Great and always Useful !!
Thanks for the video.
I have problem of applying QFutureWatcher for a single long function.
In the documentation I saw I could do like "QFuture future = QtConcurrent::run(...);"
But the problem is same documentation says I cannot use QtConcurrent::run() for progress reporting.
Do you have any idea how to handle that?
Signals and slots... I cover this in my QT design patterns course, but basically you're going to want to create a class and then use concurrent to execute a method in the class
@@VoidRealms Thank you for the reply.
But even I used signal/slot I would be in a difficult situation to calculate the progress. I should manually calculate how much progress has happened and emit a signal, right?
I found out it is impossible to progress indication when it is single method to be executed. Here is a part of a comment I found in here.
forum.qt.io/topic/31584/qfuture-and-qfuturewatcher-to-update-progress/5
"Since in this case, only a single function is called in a separate thread, QtConcurrent simply doesn't know enough to give you progress indication. What you want is a structure where you process a lot of objects using a Map or Filter method."
Am I correct?
Your videos are really helpful. Thanks a lot.
@@hareendraperera7562 you would create and track the progress inside of the class you would run... QT concurrent would have no concept of the task you're trying to perform it's going to just shove whatever you give it into a qthreadpool in the background, Make a class with a function called run inside that function you would create some steps run some code track the progress and a emit a signal
@@VoidRealms Understood. Thank you.
and I fell back in love with c++ after years of .net development.
Thank you !
Reply with your steam account we'll play :)
i think its cairnsb