Book Image

QT5 Blueprints

By : Symeon Huang
Book Image

QT5 Blueprints

By: Symeon Huang

Overview of this book

Table of Contents (17 chapters)
Qt 5 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Go back to the MainWindow class.

  2. Edit the mainwindow.ui file in the Design mode.

  3. Drag Push Button and rename it as newDownloadButton with New Download as its text.

  4. Drag Progress Bar just beneath newDownloadButton.

  5. Change the layout to Lay Out Vertically.

  6. Uncheck textVisible in the progressBar 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...