QtFtp and QtHttp "compatibility add-ons", for QHttp, and QFtp classes in Qt 5



  • From Qt 5.0.1 documentation:

    bq. The QFtp, QUrlInfo, QHttp classes are not public anymore. Use QNetworkAccessManager instead to avoid binary breaks in the future. Programs that require raw FTP/HTTP streams, can use the compatibility add-ons QtFtp and QtHttp which provides the QFtp and QHttp classes as they existed in Qt 4.

    How can we use these "compatibility add-ons"? I can't find the appropriate header files, for QHttp in particular.

    Thank you.


  • Moderators

    The whole code is in there, including headers.



  • ΟΚ, perhaps I am missing something, however everything I tried did not work.

    My .pro file is:

    @
    TEMPLATE = app
    QT += network
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .

    Input

    HEADERS += mainwindow.h
    FORMS += mainwindow.ui
    SOURCES += initialise_mirror_locations.cpp main.cpp mainwindow.cpp@

    #include <QHttp>, and #include <QtHttp> do not work.


  • Moderators

    You need to download the sources and include "this file":https://qt.gitorious.org/qt/qthttp/blobs/master/modules/qt_http.pri in your .pro. Like this:
    @
    include(path/to/that/pri/file)
    @

    At least that is my guess. If not, try including the sources into you .pro, or just analyse what is in the repo. There has to be a way to make it work :)



  • Thank you for your replies. There is a very easy way to make it work indeed. Reinstall Qt 4.8. :-)

    I am looking for a developer-friendly way to use the aforementioned "compatibility add-ons".



  • Finally, I made the switch to QNetworkAccessManager, and QNetworkReply. I was bored to do it, though. :-)

    Now the program compiles both in Qt 4.8.3, and Qt 5.0.1.



  • For the sake of completeness, the steps to use the add-ons are:

    Download the sources for the add-on from "gitorious":https://qt.gitorious.org/qt

    Extract the sources somewhere (e.g. Qt5.x.y/Src/qtmyaddon)

    Open a console in that folder

    Run qmake

    Run make (or nmake or mingw32-make or whatever)

    Run make install (nmake install, mingw32-make install, ...)

    In the .pro file of your project, add "QT += myaddon" (e.g. "QT += http")

    Run qmake on your project

    Compile your project

    Note: It's possible that step 6 requires the environment variable QTDIR to be set to the Qt5.x.y/mymakespec directory but I'm not sure about this.



  • Hi, i follow the steps that julrich list and end with: Qt5Ftp.prl, Qt5Ftpd.prl, libQt5Ftpd.a, libQt5Ftp.a and QtFtpDepends

    added "QT += ftp" in project.pro
    but i cant find "QtFtp"
    the only include i find is "QtFtp/QtFtpDepends"



  • [quote author="diego" date="1374077339"]but i cant find "QtFtp"
    the only include i find is "QtFtp/QtFtpDepends"[/quote]

    I think the include should be @#include <QFtp>@


  • Moderators

    It is merely a question of how you like to integrate the add-on's code.
    You can completely keep it completely separate from Qt 5 and compile as a separate dll.
    Personally, I consider this as a cleaner approach, since you do not mess with the rest of Qt and leave it in its "original" state.
    You would include the supplied header from where you place it and you have to add the required steps as for every lib of your own.



  • As stated in the readme, if you want "#include <QHttp>" to work you have to generate the headers:
    @cd qthttp
    <QTDIR>/bin/syncqt.pl -version 5.2.0@

    If you have already run qmake, delete the folder and download QHttp again.



  • How much different is QNetworkAccessManager from QHttp?

    I built a little utility for my laptop a long time ago and I am trying to decide between:

    • a) Migrate to QNetworkAccessManager
    • b) Apply QHttp add-on (i.e put it on life-support)
    • c) Trash it :-(

    It sounds like some here have gone though the process of migrating or installing the add-on, what was your experience / level of effort?

    Thanks! :-)



  • Hello All,
    sorry to wipe the dust off of this thread, but it seemed to me that it was smart to put my question here...

    I have a Qt5 SW which uses QNetworkAccessManager to download files from FTP servers. However, now I have to alter that software to first read contents of that FTP server (Internet refers to QtFTP add/on).

    I looked here and found instructions for install of this add on by julrich... Tried them, didn't work.

    I downloaded QtFTP from Gitorious, and put its src folder here> C:\Qt\Qt5.4.1\src.

    Opened cmd.exe, navigated to that folder
    "qmake" ENTER... and 'qmake is not recognized as an internal or external command.. blah blah"

    I have never before installed a library, and it would mean a lot to me of someone with experience would be kind enough to help.

    Thanks in advance.


  • Moderators

    @jelicicm
    Hi and welcome to devnet

    I would question if it is really necessary to go back to the compatibility version. Those have been implemented based on the new network stuff. IMHO they are meant for Qt 4 applications and their easier adaption to Qt5.

    If you have Qt creator installed it should be a matter of importing the project (e.g. QtFtp) and compilation.



  • @koahnig
    Thank you very much for your reply! Not sure how I managed to be stupid like that :)

    I included two .h and two .cpp files from /src folder in my project, wrote #include lines for two .h files and it compiled nicely!

    Now, I have to ask someone for an example code of printing out files located on FTP server.

    So far I have

    '''QFtp *ftp=new QFtp();
    QObject::connect(&ftp, SIGNAL(listInfo(const QUrlInfo &)), &ftp, SLOT(printout(const QUrlInfo &)));

    ftp->connectToHost(address);
    ftp->login("ars2014","65!tqwGfr0*8");
    ftp->list();
    ftp->close();

    And, in qftp.h and qftp.cpp I added printout>
    void QFtp::printout(const QUrlInfo &info) {
    qDebug()<<info.name().toStdString();
    }

    If it maters in any way its just a console application.

    Error I get is> error: no matching function for call to 'QObject::connect(QFtp**, const char*, QFtp**, const char*)'
    QObject::connect(&ftp, SIGNAL(listInfo(const QUrlInfo &)), &ftp, SLOT(printout(const QUrlInfo &)));

    Does someone know what is happening?

    Thanks.

    EDIT: Figured it out, I have cannot use &ftp when using connect, only just ftp. Duhh



  • The qftp sources are no longer available at https://qt.gitorious.org/qt/qtftp . Any one who can help me get the source?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Qt's sources official repositories is on code.qt.io. For QFtp it's here



  • thanks a lot!



  • @koahnig
    can you guide me on how to compile the qftp module as a separate library. I tried adding the module to my project. it works on windows but when I try running it on linux it doesn't work. my guess is I have to install it again on linux for it to work.


  • Moderators

    @avishkaperera

    You need to donwload the sources from git here as already noted by SGaist.

    When you have downloaded the files you have project files for Qt creator to load and create the libraries.


  • Moderators

    @avishkaperera

    Apparently you need nowadays to use "git" for downloading the whole stuff at once. Before there was a possibility to download all as a complete I believe.

    Are you familiar with git?

    Otherwise can download file by file, which is not so bad, but takes a bit longer.

    [edit:koahnig; Post corrected]


  • Lifetime Qt Champion

    Gitorious was a service like Gitlab, Bitbucket or Github which provide a nice graphical front-end to git itself and usually more tools to handle tasks like bug reports, merge request and nowadays continuous integration.


  • Moderators

    @SGaist
    Thanks for correction. You are right. "git" is already a complete English word. Was not careful enough to distinguish between git and gitorious.


  • Moderators

    @avishkaperera

    We had a side discussion in another part of the forum.
    There is also a place to download QFtp as an archive for those not wanting to bother with git. Only drawback is that some minor fixes are missing.



  • I found this discussion to be very helpful in my attempt to install QFtp, including the steps listed by julrich, and the download location provided by koahnig. I prepared a folder named "QFtp" under "C:\Qt\5.7\mingw53_32\include", which I put the unzipped files inside. I did receive an error, "Project ERROR: Missing CMake tests." while trying to use mingw32-make, but found discussion here which solved the problem (by creating the folder "cmake" under the "\tests\auto" sub folder.)

    • Mike

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.