Pergunta

I want to download all the files of a directory in the server. So, I do:

_ftp->list("myDirectory/");

I connect the signal listInfo, and I implemented the slot like this:

void manageFTP::on_listInfo(QUrlInfo info) 
{
    if (!info.isDir())
    {
        QString remoteFile= "remote";
        QFile *file = new QFile(info.name());
        if (file ->open(QIODevice::ReadWrite))
            _ftp->get(remoteFile, file);
    }
}

My problem is to know when the download is entirely finished because I don't know how many files are in the directory and I don't know the id of the last get. How can I know and be sure the download has finished?

Foi útil?

Solução

Your LIST and GET commands are scheduled and performed asynchronously. When the last pending command has finished QFtp emits a done(bool error) signal. So just connect a suitable slot to this signal before you execute the LIST command and you will be notified when all your commands have finished. Don't forget to disconnect the signal when done.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top