View Full Version : QFtp sample program
comlink21
20th July 2007, 01:18
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
ufo-vl
20th July 2007, 04:36
Hello,
sample program in Qt install dir: examples/network/ftp/
And also available online at: http://doc.trolltech.com/4.3/network-ftp.html
comlink21
20th July 2007, 07:46
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
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.
Here's a minimal example listing contents of ftp.trolltech.com root dir:
// main.cpp
#include <QCoreApplication>
#include <QDebug>
#include <QFtp>
class Ftp : public QFtp
{
Q_OBJECT
public:
Ftp(QObject* parent = 0)
{
connect(this, SIGNAL(listInfo(QUrlInfo)), this, SLOT(doListInfo(QUrlInfo)));
connect(this, SIGNAL(done(bool)), QCoreApplication::instance(), SLOT(quit()));
}
protected slots:
void doListInfo(const QUrlInfo& info)
{
qDebug() << info.name();
}
};
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
Ftp ftp;
ftp.connectToHost("ftp.trolltech.com");
ftp.login();
ftp.list();
ftp.close();
return app.exec();
}
#include "main.moc"
shahal
25th April 2012, 08:48
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.
Spitfire
27th April 2012, 08:59
Run qmake and then build.
Or move class definition into a header file and drop the #include "main.moc".
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.