PDA

View Full Version : Refresh QProgressBar when main thread is blocked



Rajesh.Rathod
2nd September 2015, 12:15
Dear All,
I am using Qt 4.7.3 and Windows 7.
My problem is for some time consuming process in core, I want to show progress bar from my Qt application but as main thread remains block for long time my QProgressBar is not refreshing .

Any idea , how to refresh QProgressBar if main thread is blocked.

Thanks,

anda_skoa
2nd September 2015, 13:13
Obviously the best solution is not to block the main thread.

Next best option is to split the work into smaller tasks and return to the event loop between those tasks.

Next best option is to call qApp->processEvents() during the long operation.

Cheers,
_

Rajesh.Rathod
2nd September 2015, 14:35
Thank you for your reply, but the problem is the time consuming operation process is not a part of Qt application, it is part of core DLL (Engine) and not possible to break it in small tasks.

Until main thread /qApp will get chance to execute, its not possible to call qApp->processEvents().

Thanks,

anda_skoa
2nd September 2015, 15:28
Then you have to move the processing into a separate execution context.
E.g. a thread or a sub process.

Cheers,
_