Making use of the progress bar
An intuitive way to indicate the downloading progress is by using a progress bar. In Qt, it is the QProgressBar
class that provides a horizontal or vertical progress bar widget. It uses minimum
, value
, and maximum
to determine the completed percentage. The percentage is calculated by the formula, (value – minimum) / (maximum – minimum)
. We'll use this useful widget in our example application by performing the following steps:
Go back to the
MainWindow
class.Edit the
mainwindow.ui
file in the Design mode.Drag Push Button and rename it as
newDownloadButton
withNew Download
as its text.Drag Progress Bar just beneath
newDownloadButton
.Change the layout to Lay Out Vertically.
Uncheck
textVisible
in theprogressBar
widget's property.
The push button, newDownloadButton
, is used to popup DownloadDialog
to get a new download task. We need to apply some modifications to mainwindow.h
, as suggested here:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow...