PDA

View Full Version : QFtp and dataTransferProgress



racinglocura07
24th June 2010, 13:56
Hi again! I'm having problems when i put files in the server with QFTP, the file is upload with no problem but when i want to show the transfer progress the signal datatransferprogress send a wrong value in the qint done... the first value that this signal send is 0 and the totalsize of the file and the second send the totalsize and the totasize... in 1 second this signal think that has send all the data when it is not like this.


void principal::loadFtp()
{
ftp = new QFtp;
ftp->connectToHost(dirHost);
ftp->login(hostUser,hostPass);
ftp->cd("public_html");
ftp->list();
ftp->setTransferMode(QFtp::Active);

connect(ftp,SIGNAL(dataTransferProgress(qint64,qin t64)),this,SLOT(ftpProgress(qint64,qint64)));
connect(ftp,SIGNAL(stateChanged(int)),this,SLOT(ft pStateChanged(int)));
connect(ftp,SIGNAL(commandStarted(int)),this,SLOT( ftpStart(int)));
connect(ftp,SIGNAL(commandFinished(int,bool)),this ,SLOT(ftpFinish(int,bool)));
connect(ftp,SIGNAL(listInfo(QUrlInfo)),this,SLOT(s howList(QUrlInfo)));
}


void principal::ftpProgress(qint64 done,qint64 total)
{
ui->ftpBar->setMaximum(total);
ui->ftpBar->setValue(done);
}

Vit Stepanek
24th June 2010, 15:55
The signal dataTransferProgress(qint64,qint64) emits when get() or put() is called. There are 2 overloads for a put() method. It seems that the signal is emitted only when int QFtp::put ( const QByteArray & data, const QString & file, TransferType type = Binary ) version is used. When the QIODevice* is used as a source, the documentation speaks only about emitting commandFinished() signal. If you are using QByteArray and it doesn't work, then I ran out of ideas for this moment, sorry.

racinglocura07
24th June 2010, 18:14
QByteArray buffer;

QFile file(fileName);
file.open(QIODevice::ReadOnly);
buffer = file.readAll();
buffer = buffer.toBase64();
file.close();

ftp->put(buffer,tempName,QFtp::Binary);


I think im in problems because im calling a QByteArray... Now i will test what to do
I fyou have any other suggestion please let me know them

Thank for you answer