【发布时间】:2017-04-04 10:09:27
【问题描述】:
我正在尝试将进度观察添加到 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 信号更频繁地出现?
附: libcurl进度回调日志:
Download progress: 2753 of 0
Download progress: 4141 of 0
Download progress: 5995 of 0
Download progress: 7383 of 0
...
【问题讨论】:
标签: c++ qt network-programming qnetworkaccessmanager qnetworkreply