Results 1 to 2 of 2

Thread: QFtp not connecting?

  1. #1
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question QFtp not connecting?

    having some trouble getting QFtp object to connect...

    I have private class members:
    Qt Code:
    1. QLineEdit *ftpServerLineEdit;
    2. QLineEdit *ftpUserLineEdit;
    3. QLineEdit *ftpPasswordLineEdit;
    4.  
    5. QFtp *ftp;
    6. QGraphicsView *internet;
    To copy to clipboard, switch view to plain text mode 

    but can't get a QPushbuttons connect private slot function to work with this:
    Qt Code:
    1. void MainWindow::testConnect(){
    2.  
    3. ftp = new QFtp(this);
    4.  
    5. QString server = ftpServerLineEdit->text();
    6. QString user = ftpUserLineEdit->text();
    7. QString password = ftpPasswordLineEdit->text();
    8.  
    9. QUrl url(server);
    10.  
    11. if (!url.isValid() || url.scheme().toLower != QLatinString("ftp")){
    12. ftp->connectToHost(server,21);
    13. ftp->login(user, password);
    14.  
    15. if (ftp->state() == QFtp::LoggedIn){
    16. internet->setStyleSheet(QString("background: url(:/images/Online.png);"));
    17. }
    18. else{
    19. internet->setStyleSheet(QString("background: url(:/images/Offline.png);"));
    20. }
    21. }
    22.  
    23. } //end member function
    To copy to clipboard, switch view to plain text mode 

    this never goes through the last if when I know that the hostname, username, & password are correct... can anyone help me with this? I'm sifting through the ftp example.... Is this code not getting a response from the server? therefore, just going to the last if, and then it's always false?
    Last edited by budda; 9th August 2011 at 18:03.

  2. #2
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFtp not connecting?

    Solved it... forgot to connect the commandFinished(int,bool) SIGNAL to the ftp instance of QFtp... then I did the test with the ftp->state() == QFtp::LoggedIn in the SLOT funtion

Similar Threads

  1. Qftp Put Image to FTP
    By harleyskater in forum Qt Programming
    Replies: 19
    Last Post: 5th January 2011, 08:09
  2. QFTP in LINUX
    By jsmith in forum Qt Programming
    Replies: 1
    Last Post: 2nd December 2009, 08:00
  3. Synchronizing QFtp
    By arun_vj in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2008, 13:31
  4. Replies: 0
    Last Post: 23rd September 2007, 12:54
  5. QFtp Trouble !
    By Fastman in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 13:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.