QWebEngineView加載網頁並下載

QWebEngineView

qmake: QT += webenginewidgets network
#include <QWebEngineView>
#include <QNetworkProxyFactory>
#include <QWebEngineProfile>

QNetworkProxyFactory::setUseSystemConfiguration(false);

QWebEngineView* webView = new QWebEngineView();
webView -> load(QUrl("http://download.qt.io/archive/qt/"));

QWebEngineProfile* webProfile = webView -> page() -> profile();
connect(webProfile, SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(on_webDownload(QWebEngineDownloadItem*)));

webView -> show();
void Widget::on_webDownload(QWebEngineDownloadItem *item)
{
    connect(item, SIGNAL(finished()), this, SLOT(on_downloadFinished()));
    connect(item, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(on_downloadProgress(qint64,qint64)));

    qDebug() << "item -> path(): " << item -> path();
    item -> setPath(path);
    item -> accept();
}
相關文章
相關標籤/搜索