To provide a progress display your loading routine must update the GUI control in intervals. This is usually done by performing the loading in blocks and update the progress bar after handling each chunk of data.
With Qt,
Signals & Slots | Qt Core 5.7[
^] are used for communication between objects. The
QProgressBar Class | Qt Widgets 5.7[
^] already provides the
setValue()
slot so that your loading routine can emit the signal. But that requires that your loading routine is
QObject
based.
Another solution is using a
QEvent Class | Qt Core 5.7[
^] based custom event. This custom event must then be handled in a
QProgressBar
derived class or the dialog that contains the progress bar. The event can be send by any non-Qt function - even from another thread - using
QCoreApplication::postEvent
.
An example on using
QEvent
can be found in an answer I wrote some time ago:
http://www.codeproject.com/Answers/1074217/update-change-QListWidget-item-value#answer1[
^].