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 Buttons
template.
- Add
QLabel
andQProgressBar
widgets to the form by dragging and dropping theLabel
andProgress Bar
widgets onto the form. - Set the
text
property of theLabel
widget toDownloading the file
. - Let the
objectName
property of theProgress Bar
widget be the default,progressBar
. - Save the application as
demoProgressBarThread.ui
. The form will now appear...