Easy way to download files with Qt QML and C++
- Asynchronous downloads
- Supports Qt URL schemes (http, https, ftp, custom)
- Uses QSaveFile = no corrupt or partial file downloads.
- Possible to set custom NetworkAccessManager via C++
- Self-register QML type. Plug'n'play.
Setup qpm as described in the Usage for App Developers section
qpm install com.blackgrain.qml.quickdownload
cd /path/to/projects
git clone [email protected]:Larpon/QuickDownload.git
Open quickdownload.pro
in QtCreator and build.
The result should be a *.so
plugin file.
Clone from github
cd /path/to/your/qt/project/vendor/folder
git clone [email protected]:Larpon/QuickDownload.git
Include quickdownload.pri
in your projects .pro
file
include(<path to extensions/vendor folder>/QuickDownload/quickdownload.pri)
NOTE
quickdownload.pri
auto-register the QML type Download
via the Q_CORE_STARTUP_FUNCTION
macro.
import QtQuick 2.0
import com.blackgrain.qml.quickdownload 1.0
Item {
Download {
id: download1
url: "http://placehold.it/350x150"
destination: "file:///tmp/test.png"
running: true
followRedirects: true
onRedirected: console.log('Redirected',url,'->',redirectUrl)
onStarted: console.log('Started download',url)
onError: console.error(errorString)
onProgressChanged: console.log(url,'progress:',progress)
onFinished: console.info(url,'done')
}
Download {
id: download2
url: "ftp://speedtest.tele2.net/5MB.zip"
destination: "file:///tmp/QuickDownload_test.zip"
overwrite: true
running: !download1.running
onStarted: console.log('Started download',url)
onError: console.error(errorString)
onProgressChanged: console.log(url,'progress:',progress)
onFinished: console.info(url,'done')
}
Download {
id: download3
url: "ftp://demo:[email protected]/readme.txt"
destination: "file:///tmp/QuickDownload_test_readme.txt"
overwrite: true
running: true
onStarted: console.log('Started download',url)
onError: console.error(errorString)
onProgressChanged: console.log(url,'progress:',progress)
onFinished: console.info(url,'done')
}
}