无法编译简单的Qt QFtp程序

时间:2012-03-04 01:51:44

标签: qt ftp qtnetwork

我在使用QFtp时遇到了麻烦。它根本不适合我(程序不编译)。我打破了我正在编写的主要程序为它做一个小测试应用程序(使用Qt Creator的Qt GUI应用程序),但仍然没有。所有测试应用程序都是一个按钮,按下时会生成一个新的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();
}

1 个答案:

答案 0 :(得分:0)

确保QT += network文件中有.pro

相关问题