PDA

View Full Version : QProgressBar does not update when moving window



sergey7
26th February 2015, 20:40
Hi everybody,
I'm relatively new to Qt. I've searched for a similar problem but could not find any help. So here's my problem:

My program's execution has a loop where most of the processing happens. I have a QProgressBar to show the progress in the main window. To update the QProgressBar i use qApp->processEvents(). To block any re-entries i disable all QPushButtons and other possible inputs during loop execution. It's working fine but when I move the window everything pauses until i finish this movement. Then the program continues and QProgressBar updates normally.

What I want is that even when i move the window the program will continue execution and QProgressBar will update normally. I've already tried using processEvents() with arguments but it didn't work. I also tried using repaint() in QProgressBar. It works but then when I try to move the window all the gui freezes until the operations are complete and only then it updates.

I've looked around and I've seen that using QThread is a possible solution. But since I'm not very experienced with thread programming I'd like to ask if there is any other solution in moving the window, updating QProgressBar and continuing loop execution at the same time.

d_stranz
27th February 2015, 17:16
You can do your computation in a separate thread, but all GUI activity has to take place in the main application thread. Unfortunately, because it looks like dragging the window freezes the main event loop, none of the progress signals sent from the thread will be processed either and your GUI will stay frozen.

Moving windows around on screen is a window manager (ie. Windows Explorer) function and is probably out of the control of Qt. Wiser heads may know better.