How can i get ftp files show on my list widget using QNetworkAccessManager Qt 5.8?
-
FtpDialog.cpp
#include "ftpdialog.h"
#include "ui_ftpdialog.h"FtpDialog::FtpDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FtpDialog)
{
ui->setupUi(this);
connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectClicked()));
connect(ftp, SIGNAL(finished(QNetworkReply )), this, SLOT(readRead(QNetworkReply )));
connect(ftp, SIGNAL(finished(QNetworkReply)), this, SLOT(getFiles(QNetworkReply)));ui->disconnectButton->setEnabled(false); ui->cdButton->setEnabled(false); ui->upButton->setEnabled(false); ui->getButton->setEnabled(false);
}
FtpDialog::~FtpDialog()
{
delete ui;
}void FtpDialog::connectClicked()
{
ui->connectButton->setEnabled(false);ftp->get(QNetworkRequest(QUrl("ftp.trolltech.com"))); ui->statusLabel->setText(tr("Connecting to host..."));
}
void FtpDialog::readRead(QNetworkReply *reply)
{
ui->statusLabel->setText(tr("Ready."));ui->disconnectButton->setEnabled(true); ui->cdButton->setEnabled(true); ui->upButton->setEnabled(true); ui->getButton->setEnabled(true);
}
void FtpDialog::getFiles(QNetworkReply *reply)
{QByteArray data = reply->readAll(); qDebug()<< data;
}
-
Clone it and build it.
-
What links ?
-
git://code.qt.io/qt/qtftp.git
http://code.qt.io/qt/qtftp.git
https://code.qt.io/qt/qtftp.git -
Those are links to use with the
git clone
command. -
This has nothing to do with Qt.
Didn't you get a new folder named qtftp ?
-
Open the project .pro file with Qt Creator and build it.
By the way, what OS are you on ?
-
Which version of Qt are you using to build that module ?
-
Did you install the module ?
-
Did you add
QT += ftp
to your .pro file and re-run qmake after that ?