我正在尝试构建一个在 Qt 中下载二进制文件的模块,使用QNetworkAccessManager
. 我使用文档中详述的相同方法(见下文),但是虽然我确实收到了readyRead
信号,但downloadProgress
从未到达。
一切都发生在同一个线程上(项目很大,所以我不能全部粘贴)。
有任何想法吗?
QNetworkRequest request;
request.setUrl("http://XXX.s3.amazonaws.com/XXX.exe");
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
QNetworkAccessManager * m_manager = new QNetworkAccessManager( this );
m_reply = m_manager->get(request);
m_reply->setParent(this);
connect(m_reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(m_reply, SIGNAL(downloadProgress(qint64 bytesReceived, qint64 bytesTotal)),
this, SLOT(replyDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)));