Important: Please read the Qt Code of Conduct -

Qt6 QNetworkaccessmanager FTP connection and manipulation

  • Good afternoon,
    and then guys I have a serious problem, I need to make an application in QT 6, however, I have to connect to an FTP server with a user and password, right after, I need to list all the files in a certain directory so that the user can download. I read the documentation, tested several codes but it doesn't connect and reports the following error QNetworkRequest :: ProtocolUnkwonError. Would anyone have a link with content so that I can study about FTP connections in QT 6?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The differences between Qt 5 and Qt 6 with regard to the network API are not that big so following the Qt 5 related threads you may find here will still be relevant.

    What exactly did you try ?

  • @Thiago-Dias Please post the parts relevant to building network requests.

  • #include "principalwindow.h"
    #include "ui_principalwindow.h"
    #include <QMessageBox>
    #include <QChartView>
    #include <QtCharts/QLineSeries>

    #include <QJsonArray>
    #include <QJsonDocument>
    #include <QJsonObject>
    #include <QJsonValue>

    #include <QDebug>

    QNetworkReply *reply;

    PrincipalWindow::PrincipalWindow(QWidget *parent) :
    ui(new Ui::PrincipalWindow)

    QObject::connect(json, SIGNAL(finished(QNetworkReply*)),
                         this, SLOT(jsonRequestFinished(QNetworkReply*)));
    QObject::connect(ftp, SIGNAL(finished(QNetworkReply*)),
                     this, SLOT(ftpRequestFinished(QNetworkReply*)));



    delete ui;

    void PrincipalWindow::ftpRequest(){
    QUrl url;
    QNetworkReply* reply = ftp->get(QNetworkRequest(url));
    QByteArray data = reply->readAll() ;
    qDebug() << data ;


    void PrincipalWindow::ftpRequestFinished(QNetworkReply* reply){
    if(reply->error() == QNetworkReply::NoError) {

        QString strReply = (QString)reply->readAll();
        qDebug() << strReply;
    } else {
        qDebug() << reply->error();


  • This looks properly. Strange.
    Two things I'd try:

    • first, check if the ftp scheme is supported at all (I assume the ftp is of type QNetworkAccessManager): qDebug() << ftp->supportedSchemes();
    • when setting options for QUrl add mode as TolerantMode (however this is highly unlikely to solve the problem)

    Apart from that I am out of ideas for now.

Log in to reply