O'Reilly logo

Qt 5 Blueprints by Symeon Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required