i want to implement a QProgressbar for a function in my GUI. I thought the process is simple but it seems not to be.
I thought i can implement the bar like this:
1- Button clicked 2- Progressbar and function start simultaneously 3- Function and Progressbar end simultaneously
What i have found when i searched is the update of this bar with a for-loop.I don't want to do so because my code is a simple function that must be run only one time.
Is it possible to do so ? Or am i misunderstanding something ? I found that the start and stop signals have to be managed with Threading. I wanted to ask here before i go and do further search.
Thanks.
I think the best practice is, using the main thread for
QProgressbar
orQProgressDialog
and side thread for your function.When main thread is used for your function, the UI won't be updated, even you use
for-loop
tosetValue
.What I am doing is, create a
QThread
like with a signal giving out the progress:Then set the value of
progressbar
using the number in the signal