Important: Please read the Qt Code of Conduct -

[Solved]problem using Qftp

  • hello, I'm working on an graphical application who use an FTP connection to synchronize data with a Web server.
    I previously develop the "ftp part" without graphical interface and it worked fine, but now the commands are scheduled but never executed. I can't find out why.

    there is the part of the code where I use the Qftp:

    void myFtp::run()
    this->_connectCmd = this->_ftp->connectToHost("");
    qDebug() << this->_connectCmd;

    and i connect the commandFinished and commandStarted to slots who just print with qDebug() the status of the command, but nothing is never printed after the "qDebug() << this->_connectCmd;"

    here is some additional stuff:

    my ftp class:
    class myFtp : public QObject

    explicit myFtp(QString host, QString login, QString pass, QString dir, int port, QObject *parent = 0);
    void    run();


    void    connected(bool statut);

    public slots:

    void    cmd_end(int i, bool j);
    void    cmd_start(int i);


    QString _host;
    QString _login;
    QString _pass;
    QString _dir;
    int     _port;
    bool    _connected;
    int     _connectCmd;
    int     _logCmd;
    QFtp*   _ftp;


    and where it is used in my app:

    void Widget::doConnect()
    this->lockAll(); // this is locking the interface during the connexion, i try to remove it but no change
    myFtp ftp(this->_ftpServeur, this->_login, this->_pass, this->_ftpDir, this->_ftpPort);;

    thanks for your help and don't hesitate to give me advice if I you see some ... improbable code style.

  • connectToHost is asynchronous, so you may want to create your ftp object (in doConnect method) on the heap using new...

  • ho that's right thanks. It's working now.

Log in to reply