赞
踩
一、效果图
二、代码
void WebDownloadWork::on_WebDownload(QWebEngineDownloadItem *item)
{
connect(item,&QWebEngineDownloadItem::finished,this,&WebDownloadWork::on_finished);
connect(item,&QWebEngineDownloadItem::downloadProgress,this,&WebDownloadWork::on_downloadProgress);
item->accept();
}
void WebDownloadWork::on_finished()
{
qDebug()<<"WebDownloadWork::on_finished";
}
void WebDownloadWork::on_downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
qDebug()<<"WebDownloadWork::on_downloadProgress bytesReceived:"<<bytesReceived<<" bytesTotal:"<<bytesTotal;
}
三、总结
1.网页下载会触发QWebEngineView->QWebEnginePage->QWebEngineProfile 中的 void downloadRequested(QWebEngineDownloadItem *download);
2.QWebEngineDownloadItem管理每次触发的下载请求,可以设置文件下载路径和下载名称
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。