Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Download Data from URL
Jump to navigation
Jump to search
Download Data from URL
The following code snippet demonstrates how to download data as QByteArray [qt.io] from URL. The downloaded data can be saved as a file or converted to appropriate object. For example if an image is downloaded it can be converted to QPixmap [qt.io] or QImage [qt.io] using method loadFromData() [qt.io]
Please note that although the name of the class is FileDownloader the downloaded data is not saved on the disk as file!
Important Classes
- QNetworkAccessManager [qt.io]
- QNetworkRequest [qt.io]
- QNetworkReply [qt.io]
- QUrl [qt.io]
.pro File
If you are targeting Symbian devices remember to add the capability for network services.
filedownloader.h
filedownloader.cpp
Usage
Load Pixmap from URL
- Declare slot
- Connect signal downloaded() to the slot
- Load QPixmap from the downloaded data