Important: Please read the Qt Code of Conduct -

Qtftp module bug under qt 5.6

  • Hello everyone. Since I needed to recover all the files on an FTP server, I had to install the qtftp module in Qt 5.6 (which slowed me down because it was quite a puzzle).
    My code to recover all the files works correctly under Qt 4.7.4 but not under Qt 5.6.
    There is no special error except that the path of the tree does not work properly.
    Has anyone ever encountered this kind of problem?

  • Lifetime Qt Champion

    Hi and welcome
    I have not seen any reports on its not working. Its no longer maintained and
    it might have issues that not been reported here.

    Searching the forum only showed posts about
    build/installing it but not that it it almost worked but
    some elements did not.

    When you say "path of the tree does not work properly."
    what does that mean ?

  • it means that under Qt 4.7.4 when I have a file tree like
    B-> A-> C
    B-> B-> D-> R
    B-> X> Y
    B-> Z
    B-> E-> F-> G-> D
    B-> E-> X, E-> W

    the search works correctly, that mean it accesses all the folders of the tree but under Qt 5.6 it accesses the elements of B which represents the root here and also B-> A but from there it goes in all directions by wanting for example to access B-> A-> G which does not exist so it bug

  • Lifetime Qt Champion

    @magloire-touh Can you please show the code you are using to achive this?

  • class MainWindow : public QMainWindow

    public slots:
    void handleListInfo(QUrlInfo info);
    void getAllFilesFromFtp();
    void handleCommandFinished( int id, bool error );

    QFtp *ftp;
    QList<QUrlInfo> ftpFilesList;
    QQueue<QString> ftpFolders;
    QString currentFtpFolder;

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)
    ftp = new QFtp();
    connect(ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(handleListInfo(QUrlInfo)));
    connect(ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(handleCommandFinished(int,bool)));

    void MainWindow::handleListInfo(QUrlInfo info){
    qDebug() << currentFtpFolder+'/';
    } else if(info.isDir()){

    void MainWindow::getAllFilesFromFtpDir(){

    void MainWindow::handleCommandFinished( int id, bool error ){
    if(ftp->currentCommand() == QFtp::List){
    currentFtpFolder = ftpFolders.dequeue();
    qDebug() << QString::number(ftpFilesList.count())+" éléments trouvés !";

  • Lifetime Qt Champion

    @magloire-touh said in Qtftp module bug under qt 5.6:

    void MainWindow::handleCommandFinished( int id, bool error ){

    I don't have experience with QFtp, but reading the docs I understand that QFtp is fully asynchronous. I.e. every command (including cd) is queued and executed in background, emitting a finished signal afterwards.

    For further debugging, I recommend you to add a qDebug at the start of your finished handler:

    void MainWindow::handleCommandFinished( int id, bool error )
       qDebug() << "handleCommandFinished(" << id << "," << error ")";
    // ...

    That way you can trace the execution and compare what happens under Qt 4.7 and Qt 5.6

  • QFtp became also deprecated towards the end of Qt4 main stream development.

    AFAIK is the QtFtp module for Qt 5 only a recreation of the functionality as available through QFtp in Qt 4.

    I have switched from Qt 4 to Qt 5 probably around Qt 5.1. I had downloaded QtFtp at that time and it contains follwoing note:

    This repository contains deprecated APIs which have been removed from Qt

    Applications are recommended to port to the supported APIs.
    However as some features are lost, these APIs are provided as standalone
    source code for applications that require removed features.

    Therefore, my interpretation this is merely some sort of courtesy module, but it is no longer part of Qt libraries. Also in the course of changes in Qt libs it was already expected that this may not continue to work all the time.

  • Lifetime Qt Champion

    I think you have to debug the ftp code to find out what goes wrong.
    From reading the code nothing sprang to eye.
    Also as @aha_1980 suggest putting in lots of qDebug to help show
    what exactly is going wrong.
    But it sounds like
    its ftp->cd and list() but
    without running it, its hard to tell what issue is.

  • @aha_1980 death of laughter. I followed your advice and traced all the execution and it is not the code of recovery the list of the files which does not work but it was rather the fact of called twice the method getAllFilesFromFtpDir () which has fucked up the mess. Thank you

  • Lifetime Qt Champion

    Oh so it still works as it should ?
    Good news :)

  • @mrjj yes. Everything correct. Thanks for the help

Log in to reply