如何在QT中连接到FTP服务器

时间:2015-07-21 02:19:49

标签: c++ qt ftp

我正在尝试连接到FTP服务器,但我遇到了以下问题:

  

QObject :: connect:没有这样的插槽Object :: replyFinished   在... \这里我的程序名......

我的错误在哪里?我想它在以下代码中:

///////////////Connection.h file////////

class Connection : public QObject 
{
 public:
     explicit Connection(QObject *parent=0);

     Connection(QString uri, QString usernmae, QString password);

     void FTP_Connection();  

     public slots:
         void replyFinished(QNetworkReply *);

    private:
        QString URI;
        QString USERNAME;
        QString PASSWORD;

       QNetworkAccessManager *manager;

   };  

  ///////////////Connection.cpp file////////
   Connection::Connection(QString uri, QString usernmae, QString password)
    {
       this->URI=uri;
       this->USERNAME=usernmae;
       this->PASSWORD=password;
    }
    void Connection::FTP_Connection()
    {
       QUrl url(this->URI);
       url.setUserName(this->USERNAME);
       url.setPassword(this->PASSWORD);
       url.setPort(21);

       QNetworkRequest request(url);

       manager=new QNetworkAccessManager(this);

      connect(manager,
              SIGNAL(finished(QNetworkReply*)),
              this,
              SLOT(replyFinished(QNetworkReply *)));

             manager->get(request);
     } 
     ///////////////main.cpp file////////

      int main(int argc, char *argv[])
     {
        QCoreApplication a(argc, argv);

        Connection *con=new Connection("ftp://192.168.3.62//",
                                       "win7",
                                       "053253");

        con->FTP_Connection();

        return a.exec();
        }

0 个答案:

没有答案