• 4575阅读
  • 2回复

急急!!友善MINI2440上开发一个FTP客户端,可是编译出现问题! [复制链接]

上一主题 下一主题
离线tangji612
 

只看楼主 倒序阅读 楼主  发表于: 2009-11-04
已经修改了qconfig-qpe.h文件了,并重新configure和make,操作如下:
#//define QT_NO_NETWORKPROTOCOL

可是编译程序还是出现如下问题:

ftpclient.cpp: In member function ‘void FtpClient::slotLogin()’:
ftpclient.cpp:80: 错误:‘class QFtp’没有名为‘connectToHost’的成员
ftpclient.cpp:85: 错误:‘class QFtp’没有名为‘login’的成员
ftpclient.cpp: In member function ‘void FtpClient::slotPut()’:
ftpclient.cpp:97: 错误:‘class QFtp’没有名为‘put’的成员
ftpclient.cpp: In member function ‘void FtpClient::slotGet()’:
ftpclient.cpp:110: 错误:‘WriteOnly’不是‘QIODevice’的成员
ftpclient.cpp:111: 错误:‘class QFtp’没有名为‘get’的成员
ftpclient.cpp: In member function ‘void FtpClient::slotStateChanged(int)’:
ftpclient.cpp:118: 错误:‘LoggedIn’不是‘QFtp’的成员
ftpclient.cpp: In member function ‘void FtpClient::slotDone(bool)’:
ftpclient.cpp:129: 错误:‘class QFtp’没有名为‘errorString’的成员
make: *** [.obj/release-shared/ftpclient.o] 错误 1

源程序:
#ifndef FTPCLIENT_H
#define FTPCLIENT_H

#include <qdialog.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qlayout.h>
#include <qstring.h>
#include <qmessagebox.h>
#include <qinputdialog.h>
#include <qftp.h>

class FtpClient : public QDialog
{
    Q_OBJECT
public:
    FtpClient(QWidget * parent = 0, const char * name="myftp" , bool modal = FALSE, WFlags f = 0);
    ~FtpClient();
public:
    QLabel* LabelServer;
    QLineEdit* LineEditServer;
    QLabel* LabelUser;
    QLineEdit* LineEditUser;
    QLabel* LabelPassword;
    QLineEdit* LineEditPassword;
        QPushButton* PushButtonLogin;
       QPushButton* PushButtonPut;
        QPushButton* PushButtonGet;

    enum STATUS{None,LOGIN,PUT,GET};
    STATUS curStatus;
    
    QFtp *ftpClient;
    QFile *localFile;
    
public slots:
    void slotLogin();
    void slotPut();
    void slotGet();
    void slotStateChanged ( int state );
    void slotDone ( bool error );
};


#endif



#include "ftpclient.h"

FtpClient::FtpClient( QWidget * parent , const char * name , bool modal , WFlags f)
    : QDialog( parent,name,modal, f )
{  
    
    LabelServer = new QLabel( this );
    LabelServer->setText(tr("Server Address:"));
    
    LineEditServer = new QLineEdit( this );
    
    LabelUser = new QLabel( this );
    LabelUser->setText(tr("User Name:"));
    
    LineEditUser = new QLineEdit( this );
    
    LabelPassword = new QLabel( this );
    LabelPassword->setText(tr("Password:"));
    
    LineEditPassword = new QLineEdit( this );
        
    PushButtonLogin = new QPushButton( this);
    PushButtonLogin->setText( tr( "Login" ) );  
    
    PushButtonPut = new QPushButton( this);
    PushButtonPut->setText( tr( "Put" ) );      
    
    PushButtonGet = new QPushButton( this);
    PushButtonGet->setText( tr( "Get" ) );      
    
    QGridLayout *gLayout = new QGridLayout();
    gLayout->addWidget( LabelServer,0,0 );
    gLayout->addWidget( LineEditServer,0,1 );
    gLayout->addWidget( LabelUser,1,0 );
    gLayout->addWidget( LineEditUser,1,1 );
    gLayout->addWidget( LabelPassword,2,0 );
    gLayout->addWidget( LineEditPassword,2,1 );
    
    QHBoxLayout *hbLayout = new QHBoxLayout();
    hbLayout->addWidget( PushButtonPut );
    hbLayout->addWidget( PushButtonGet );
    
    QVBoxLayout *vbLayout = new QVBoxLayout( this );
    vbLayout->addLayout( gLayout );
    vbLayout->addWidget( PushButtonLogin );
    vbLayout->addLayout( hbLayout );

    connect(PushButtonLogin,SIGNAL(clicked()),this,SLOT(slotLogin()));
    connect(PushButtonPut,SIGNAL(clicked()),this,SLOT(slotPut()));
    connect(PushButtonGet,SIGNAL(clicked()),this,SLOT(slotGet()));
    
    PushButtonPut->setEnabled(false);
    PushButtonGet->setEnabled(false);
    
    curStatus=None;
}

FtpClient::~FtpClient()
{
}
                                                                            
void FtpClient::slotLogin()                    
{          
    QString serverAddress = LineEditServer->text();
    if(serverAddress.isEmpty())
    {
        QMessageBox::warning(this,tr("error"),tr("Please input server address!"));
        return;
    }
    QString userName = LineEditUser->text();
    if(userName.isEmpty())
    {
        QMessageBox::warning(this,tr("error"),tr("Please input user name!"));
        return;
    }    
    QString password = LineEditPassword->text();
    
    ftpClient=new QFtp();
    ftpClient->connectToHost(serverAddress,21);
    
    connect(ftpClient, SIGNAL(stateChanged ( int )), this, SLOT(slotStateChanged ( int ) ) );
    connect(ftpClient, SIGNAL(done ( bool )), this, SLOT(slotDone ( bool ) ) );
    
    ftpClient->login(userName,password);
    curStatus=LOGIN;  
}

void FtpClient::slotPut()                    
{          
    bool ok;
    QString fileName = QInputDialog::getText(tr("Put File:"),
        tr("Please input file name:"), QLineEdit::Normal, QString(), &ok,this);  
    if(ok && !fileName.isEmpty())
    {
        QFile *remoteFileName=new QFile(fileName);
        ftpClient->put(remoteFileName, fileName);
    }
    curStatus=PUT;
}

void FtpClient::slotGet()
{        
    bool ok;
    QString fileName = QInputDialog::getText(tr("Get File:"),
        tr("Please input file name:"), QLineEdit::Normal, QString(), &ok,this);  
    if(ok && !fileName.isEmpty())
    {
        localFile=new QFile(fileName);    
        localFile->open(QIODevice::WriteOnly);
        ftpClient->get(fileName,localFile);
    }    
    curStatus=GET;  
}

void FtpClient::slotStateChanged ( int state )
{
    if(state == QFtp::LoggedIn)
    {
        PushButtonPut->setEnabled(true);
        PushButtonGet->setEnabled(true);
    }
}

void FtpClient::slotDone(bool error)
{
    if(error)
    {
        QMessageBox::warning(this,tr("error"),ftpClient->errorString());
        return;
    }
    if(curStatus == LOGIN)
    {
        PushButtonLogin->setEnabled(false);
        curStatus=None;
    }    
    if(curStatus == PUT)
    {
        QMessageBox::information(this,tr("succeed"),tr("Put file succeed!"));
        curStatus=None;
    }
    if(curStatus == GET)
    {
        localFile->close();
        QMessageBox::information(this,tr("succeed"),tr("Get file succeed!"));
        curStatus=None;
    }
}
离线tangji612

只看该作者 1楼 发表于: 2009-11-05
没有人碰到同样的问题啊!主要想做一个是 mini2440上qtopia应用程序的FTP客户端(x86-qtopia版本)
已经修改过这个友善的x86-qtopia版本的qconfig-qpe.h文件,并从新configure和make了,可是在这底下编译还是
出现如下问题,不解???请哪位高人指点一下!谢谢!
离线tangji612

只看该作者 2楼 发表于: 2009-11-05
源程序发上来,哪位高人指教一下!
附件: ftpclient.tar.gz (66 K) 下载次数:7
快速回复
限100 字节
 
上一个 下一个