Results 1 to 8 of 8

Thread: QFtp sample program

  1. #1
    Join Date
    Jul 2007
    Posts
    8
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QFtp sample program

    Does anyone outhere have experience creating program using QFtp class..?, if you don't mind plz give me sample copy of that program.
    thank for help.
    comlink21

  2. #2
    Join Date
    Jul 2007
    Posts
    27
    Thanks
    4
    Thanked 1 Time in 1 Post

    Smile Re: QFtp sample program

    Hello,
    sample program in Qt install dir: examples/network/ftp/

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QFtp sample program

    And also available online at: http://doc.trolltech.com/4.3/network-ftp.html
    J-P Nurmi

  4. #4
    Join Date
    Jul 2007
    Posts
    8
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: QFtp sample program

    Thank you for the answer, but sorry i didn't mention before. waht i want is sample program not under GUI environment. actually i have test the following program but not run.

    #include <QFtp>
    #include <iostream>

    using namespace std;

    int main(int argc, char ** argv)
    {
    Qftp *ftp = new Qftp ();
    ftp->connectToHost("ftp.trolltech.com");
    ftp->login("","");
    ftp->list();
    ftp->close();
    return 0;
    }

    when i compile there is no error, but when i call the program there is command:
    QObject::startTimer:QTimer can only be used with threads started with QThread
    your help is appreciated.
    thanks
    comlink21

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QFtp sample program

    From QFtp docs:
    The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.
    You must construct an application object and enter to an event loop. QFtp will inform you via signals when something happens.
    J-P Nurmi

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QFtp sample program

    Here's a minimal example listing contents of ftp.trolltech.com root dir:
    Qt Code:
    1. // main.cpp
    2. #include <QCoreApplication>
    3. #include <QDebug>
    4. #include <QFtp>
    5.  
    6. class Ftp : public QFtp
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. Ftp(QObject* parent = 0)
    12. {
    13. connect(this, SIGNAL(listInfo(QUrlInfo)), this, SLOT(doListInfo(QUrlInfo)));
    14. connect(this, SIGNAL(done(bool)), QCoreApplication::instance(), SLOT(quit()));
    15. }
    16.  
    17. protected slots:
    18. void doListInfo(const QUrlInfo& info)
    19. {
    20. qDebug() << info.name();
    21. }
    22. };
    23.  
    24. int main(int argc, char* argv[])
    25. {
    26. QCoreApplication app(argc, argv);
    27.  
    28. Ftp ftp;
    29. ftp.connectToHost("ftp.trolltech.com");
    30. ftp.login();
    31. ftp.list();
    32. ftp.close();
    33.  
    34. return app.exec();
    35. }
    36.  
    37. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  7. #7
    Join Date
    Apr 2012
    Posts
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QFtp sample program

    Hi

    I am trying to use the above mentioned code but am running nto issues. I see the following:

    :-1: error: No rule to make target `debug/main.moc', needed by `debug/Ftp.o'. Stop.

    Any idea how to fix this?


    Thanks in advance.

  8. #8
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFtp sample program

    Run qmake and then build.

    Or move class definition into a header file and drop the #include "main.moc".

Similar Threads

  1. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19

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.