2012-03-04 142 views
1

我無法使用QFtp。它根本不適合我(程序不能編譯)。我打破了我編寫的主要程序,爲它做了一個小測試應用程序(使用Qt Creator的Qt GUI應用程序),但仍然沒有任何結果。所有的測試應用程序都是一個按鈕,當按下時會產生一個新的QFtp,並嘗試連接到主機並登錄(不會編譯!!)。我收到以下錯誤:無法編譯簡單的Qt QFtp程序

debug/mainwindow.o: In function `ZN10MainWindow21on_pushButton_clickedEv': 
C:\Users\Juan\Documents\QtProjects\ftpppp/mainwindow.cpp:19: undefined reference to `_imp___ZN4QFtpC1EP7QObject' 
C:\Users\Juan\Documents\QtProjects\ftpppp/mainwindow.cpp:20: undefined reference to `_imp___ZN4QFtp13connectToHostERK7QStringt' 
C:\Users\Juan\Documents\QtProjects\ftpppp/mainwindow.cpp:21: undefined reference to `_imp___ZN4QFtp5loginERK7QStringS2_' 
collect2: ld returned 1 exit status 
mingw32-make.exe[1]: *** [debug\ftpppp.exe] Error 1 
mingw32-make.exe: *** [debug] Error 2 

下面是代碼:

#include "mainwindow.h" 
#include "ui_mainwindow.h" 
#include <QtNetwork/QFtp> 

MainWindow::MainWindow(QWidget *parent) : 
    QMainWindow(parent), 
    ui(new Ui::MainWindow) 
{ 
    ui->setupUi(this); 
} 

MainWindow::~MainWindow() 
{ 
    delete ui; 
} 

void MainWindow::on_pushButton_clicked() 
{ 
    QFtp *q = new QFtp(); 
    q->connectToHost("ftp.anydomain.com"); 
    q->login(); 
} 

回答

0

確保您在.pro文件中有QT += network