Utilizing QNetworkAccessManager

Now, we're going to discover how to write an application that is able to download files from other locations. By other locations, we mean that you can download files from a local position; it doesn't have to be an Internet address, since the local file URLs are supported by Qt as well.

First of all, let's create a Downloader class that will use QNetworkAccessManager to do the downloading work for us. The downloader.h header file is pasted shown as follows:

#ifndef DOWNLOADER_H #define DOWNLOADER_H #include <QObject> #include <QNetworkAccessManager> #include <QNetworkRequest> #include <QNetworkReply> class Downloader : public QObject { Q_OBJECT public: explicit Downloader(QObject *parent = 0); public slots: void download(const ...

Get Qt 5 Blueprints now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.