#include "ui_cl.h"#include "client.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); QWidget *widget = new QWidget; client ui; ui.setupUi(widget); widget->show(); ui.ftpconnect("mysite.net","test","test"); ui.textEdit->textCursor().insertText("FTP command"); return app.exec();}
class client : public Ui_widget,QWidget { public: QFtp *ftp; client(QWidget *parent = 0){ ftp = new QFtp(); connect(ftp, SIGNAL(commandStarted(int)), this, SLOT(ftpStartCommand(int))); }; void ftpconnect(QString sn,QString un,QString pw){ ftp->connectToHost(sn,21); ftp->login(un,pw); }; private slots: void ftpStartCommand(int i){ textEdit->textCursor().insertText("Test FTP command"); };};
#include "client.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); client widget; widget.show(); return app.exec();}
#include <QApplication>#include <QFont>#include <QFtp>#include <QLCDNumber>#include <QPushButton>#include <QSlider>#include <QVBoxLayout>#include <QHBoxLayout>#include <QTextEdit>#include <QTextCursor>#include <QProgressBar>#include <QSpacerItem>#include <QWidget>class client : public QWidget{ private slots: void ftpCommand(int,bool); void ftpCommand1(int); public: QFtp *ftp; QVBoxLayout *vbl; QHBoxLayout *hbl; QProgressBar *pg; QPushButton *eb; QTextEdit *te; QSpacerItem *spi; client(QWidget *parent = 0); void ftpC(QString sn, QString un, QString pw);};void client::ftpC(QString sn, QString un, QString pw){ QApplication::setOverrideCursor(Qt::WaitCursor); ftp->connectToHost(sn); ftp->login(un,pw); ftp->list();};void client::ftpCommand(int i, bool b){ te->textCursor().insertText("Test ftp command");};void client::ftpCommand1(int i){ te->textCursor().insertText("Test ftp command");};client::client(QWidget *parent): QWidget(parent){ ftp = new QFtp(this); vbl = new QVBoxLayout(parent); pg = new QProgressBar(); hbl = new QHBoxLayout(); eb = new QPushButton("Quit"); spi = new QSpacerItem(40,20, QSizePolicy::Expanding, QSizePolicy::Minimum); te = new QTextEdit(); vbl->addWidget(pg); vbl->addWidget(te); hbl->addItem(spi); hbl->addWidget(eb); vbl->addLayout(hbl); setLayout(vbl); /////////////////// /////////////////// pg->setValue(5); te->setReadOnly(true); ////////////////// connect(eb, SIGNAL(clicked()), qApp, SLOT(quit()));// connect(ftp, SIGNAL(commandFinished(int,bool)), qApp, SLOT(quit())); connect(ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftpCommand(int,bool))); connect(ftp, SIGNAL(commandStarted(int)), this, SLOT(ftpCommand1(int))); ftpC("mysite.net","test","test"); QApplication::restoreOverrideCursor();}
connect(ftp, SIGNAL(commandFinished(int,bool)), qApp, SLOT(quit()));
connect(ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftpCommand(int,bool)));
connect(ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(quit()));
class client : public QWidget{ Q_OBJECT private slots: void ftpCommand(int i,bool b){ te->textCursor().insertText("Test ftp command"); }; void ftpCommand1(int i){ te->textCursor().insertText("Test ftp command"); }; public: QFtp *ftp; QVBoxLayout *vbl; QHBoxLayout *hbl; QProgressBar *pg; QPushButton *eb; QTextEdit *te; QSpacerItem *spi; client(QWidget *parent = 0){ ftp = new QFtp(this); vbl = new QVBoxLayout(parent); pg = new QProgressBar(); hbl = new QHBoxLayout(); eb = new QPushButton("Quit"); spi = new QSpacerItem(40,20, QSizePolicy::Expanding, QSizePolicy::Minimum); te = new QTextEdit(); vbl->addWidget(pg); vbl->addWidget(te); hbl->addItem(spi); hbl->addWidget(eb); vbl->addLayout(hbl); setLayout(vbl); /////////////////// // /////////////////// pg->setValue(5); te->setReadOnly(true); ////////////////// connect(eb, SIGNAL(clicked()), qApp, SLOT(quit())); //connect(ftp, SIGNAL(commandFinished(int,bool)), qApp, SLOT(ftpCommand(int,bool))); connect(ftp, SIGNAL(commandStarted(int)), this, SLOT(ftpCommand1(int))); ftpC("mysite.net","test","test");// this->ftpCommand(1, true); }; void ftpC(QString sn, QString un, QString pw){ ftp->connectToHost(sn); ftp->login(un,pw); ftp->list(); };};