PDA

View Full Version : SIGNAL in QNetworkReply error - SOLVED -



monillo
14th May 2015, 14:16
Hello everybody:

In a small app that download a file from a url, I have this code:

MyClasse.h


...
...
private slots:
void downloadProgressShow(quint64 bytesRead, quint64 bytesTotal);
...
...


myclasse.cpp


...
...
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,qint6 4)),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.

wysota
14th May 2015, 14:28
No, qint64 and quint64 are different types.

Lesiok
14th May 2015, 14:30
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 ?

monillo
14th May 2015, 15:25
Thanks for the reply.

Really I need clean my glasses

ChrisW67
14th May 2015, 23:04
You should also see a run time warning message that the connect() call failed because the target was missing.