我正在尝试将进度观察添加到 Qt 的FileDownloader示例中。
它有效,但不是我想要的方式 -downloadProgress
信号太罕见了!
约 300 Kb 文件只需两次。
这使得无法在 GUI 中流畅地显示下载进度。
编码:
...
QNetworkReply* reply = m_WebCtrl.get(request);
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(onDownloadProgress(qint64,qint64)));
void FileDownloader::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
qDebug() << "Download progress:" << bytesReceived << bytesTotal;
}
输出:
Download progress: 19954 from -1
Download progress: 288322 from -1
Download progress: 288322 from 288322
有没有办法让downloadProgress
信号来得更频繁?
PSlibcurl
进度回调日志:
Download progress: 2753 of 0
Download progress: 4141 of 0
Download progress: 5995 of 0
Download progress: 7383 of 0
...