Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm writing a program using QT. Whenever I let the QProgressBar to preceed, it stucks the window.I then can not operate on the window and my program runs very slow. I've tried both qt4 and qt5 on both windows and linux. the result is the same. Does anyone encounter the same question?
Posted

1 solution

You should use a worker thread for the purpose of updating the progress bar. See, for instance, the following discussion: "(seemingly) simple Qt app: creating a progress bar"[^].
 
Share this answer
 
Comments
曦 陈 15-Apr-14 8:23am    
Well, My problem is different from that. the progressbar makes the whole program crash. I've tried three computers, and the result is the same.
CPallini 15-Apr-14 8:28am    
This scenario is rather different from the one of your original post. If the UI hangs then you have to use a worker thread. On the other hand, if your program crashes then you have to fix your code (and we cannot help without seeing your code).
曦 陈 15-Apr-14 8:51am    
Just very basic code sample like

progressBar->setMaximun(max);
for ( int i=0; i<max; ++i="" )
{
="" progressbar-="">setValue(i);
sleep(1);
}
CPallini 15-Apr-14 8:54am    
Such a code, in the main thread, would hang the UI.
曦 陈 15-Apr-14 20:58pm    
I understand now. The program can not response since it's in sleep. But What I want to implement is, a process write to a pipe, another process read the data from the pipe and update the progressbar. A block read is the same as sleep, it would hang the process. However, a non-block read is too wasty. Any suggestion?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900