SIGNAL in QNetworkReply error - SOLVED -
Hello everybody:
In a small app that download a file from a url, I have this code:
MyClasse.h
Code:
...
...
private slots:
void downloadProgressShow(quint64 bytesRead, quint64 bytesTotal);
...
...
myclasse.cpp
Code:
...
...
void MyClasse::on_btnDownload_clicked()
{
...
QNetworkAccessManager *manager = new QNetworkAccessMananger(this);
QNetworkReply
*reply
= manager
->get
(QNetworkRequest
(QUrl("http://www .....")));
// --- Show the progress.
connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadProgressShow(qint64,quint64)));
// --- When download finished, save the file.
connect(manager,SIGNAL(finished(QNetworkReply *)),this,SLOT(saveFileDownloaded(QNetworkReply *)));
}
void MyClasse::downloadProgressShow(qint64 bytesRead, quint64 bytesTotal)
{
qDebug
() <<
QString::number(bytesRead
).
toLatin1() + " bytes of " + QString::number(bytesTotal
).
toLatin1();
}
The file download is correctly, but the progressbar is not refreshed. The application output of Qt Creator say:
QObject::connect: Incompatible sender/receiver arguments
QNetworkReplyHttpImpl::downloadProgress(qint64,qin t64) --> Classe::downloadProgressShow(qint64,quint64)
But really the functions of SIGNAL and SLOT are the same arguments, or not?
Thanks in advance.
Re: SIGNAL in QNetworkReply error
No, qint64 and quint64 are different types.
Re: SIGNAL in QNetworkReply error
From the QNetworkReply::downloadProgress doc : If the number of bytes to be downloaded is not known, bytesTotal will be -1. How You want to convert it to the unsigned type ?
Re: SIGNAL in QNetworkReply error
Thanks for the reply.
Really I need clean my glasses
Re: SIGNAL in QNetworkReply error
You should also see a run time warning message that the connect() call failed because the target was missing.