Question

I'm having trouble using QFtp. It simply isn't working for me (program doesn't compile). I broke out of the main program I'm coding to do a little test app for it (a Qt GUI application using Qt Creator) and still nothing. All the test app is is a button that makes a new QFtp when pressed and attempts to connect to a host and login (doesnt compile!!). I get the following errors:

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

Here is the code:

#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();
}
Was it helpful?

Solution

Make sure you have QT += network in your .pro file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top