Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [Solved]problem using Qftp

    General and Desktop
    2
    3
    1687
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Aicou last edited by

      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("ftp.qt.nokia.com");
      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
      {
      Q_OBJECT
      public:

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

      signals:

      void    connected(bool statut);
      

      public slots:

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

      private:

      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);
      ftp.run();
      }
      @

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

      1 Reply Last reply Reply Quote 0
      • M
        maxpayne last edited by

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

        http://doc.qt.nokia.com/latest/qftp.html#details

        1 Reply Last reply Reply Quote 0
        • A
          Aicou last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post