Updating progress bar using thread
Progress bars are actively used in applications to indicate that a task is working in the background. Threads also do the same; threads too work in the background and do their assigned task. Let's see how the progress bar and threads can be linked.
In this recipe, we will be displaying a progress bar that is being updated using threads. The value in the progress bar will be updated through a running thread.
How to do it...
To associate a progress bar with a thread and to update the progress bar interactively via the thread, use the following steps:
- Let's create an application based on the
Dialog without Buttonstemplate.
- Add
QLabelandQProgressBarwidgets to the form by dragging and dropping theLabelandProgress Barwidgets onto the form. - Set the
textproperty of theLabelwidget toDownloading the file. - Let the
objectNameproperty of theProgress Barwidget be the default,progressBar. - Save the application asÂ
demoProgressBarThread.ui. The form will now appear...