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

Introducing Qt network programming


Qt supports network programming and provides lots of high-level APIs to ease your work. QNetworkRequest, QNetworkReply, and QNetworkAccessManager use common protocols to perform network operations. Qt also offers lower-level classes to represent low level network concepts.

In this chapter, we're going to utilize the high-level APIs that Qt has offered to write a downloader to retrieve the Internet files and save them to your disk. As I mentioned earlier, the application will need the QNetworkRequest, QNetworkReply, and QNetworkAccessManager classes.

Firstly, all network requests are represented by the QNetworkRequest class, which is a general container for information associated with a request, including the header and encryption. Currently, HTTP, FTP, and local file URLs are supported for uploading and downloading.

Once a request has been created, the QNetworkAccessManager class is used to dispatch it and emits signals, reporting the progress. Then, it creates...