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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.