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);
...
...
...
...
private slots:
void downloadProgressShow(quint64 bytesRead, quint64 bytesTotal);
...
...
To copy to clipboard, switch view to plain text mode
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,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();
}
...
...
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();
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks