QT5 QFtp class used (Modules adding ftp)

QT5 how to use QFtp class (module adding ftp)

 

However, after Qt5.x, Qt Network has undergone great changes, Assistant About This section describes the following:

The QFtp and QUrlInfo classes are no longer exported. Use QNetworkAccessManager instead. Programs that require raw FTP or HTTP streams can use the Qt FTP and Qt HTTP compatibility add-on modules that provide the QFtp and QHttp classes as they existed in Qt 4.

This means that: no longer export QFtp and QUrlInfo class, instead QNetworkAccessManager.

 

QNetworkAccessManager can use to upload / download Ftp's (Reference: Qt's FTP upload / download), but some of the original QFtp QNetworkAccessManager does not provide some features, such as: list, cd, remove, mkdir, rmdir, rename and so on. In this case, you have to use QFtp, it is fortunate that QFtp been maintained only need to download the source code to compile can be used.

1. Download QFtp Source

QFtp download from GitHub:

https://github.com/qt/qtftp

Or download using the command:

git clone https://github.com/qtproject/qtftp

 

2.  Compile

Open the project as compiled by QTCreator.

4. Compile a dynamic library, static library

Modify qtftp \ src \ qftp \ ftp.pro file

The original two CONFIG amended as follows:

       CONFIG += static

       CONFIG += shared

Then compiled compiled will build directory \ lib \ directory swells to give a dynamic library static library files we need.

http://img1.51cto.com/attachment/201308/164006371.png

5. deploy the compiled library

 

5.1 The dynamic link library (.dll files) copied to Qt5.9.8 \ 5.9.8 \ mingw53_32 \ bin directory

5.2 static libraries (.a files) and copy the file to .prl Qt5.9.8 \ 5.9.8 \ mingw53_32 \ lib directory

5.3 QtFtp files in the build directory / include / directory copy the folder to Qt5.9.8 \ 5.9.8 \ mingw53_32 \ include directory

5.4 The \ qtftp \ two headers qftp.h and qurlinfo.h under src \ qftp directory

Copied to \ 5.9.8 \ mingw53_32 \ \ directory under Qt5.9.8 include QtFtp

5.4.1 Creating a file QFtp attention in this directory has no extension

5.4.2 This QFtp file with Notepad open, and in which the write #include "qftp.h"

5.5 will build directory files \ mkspecs \ modules-inst \ qt_lib_ftp.pri copy to Qt5.9.8 \ 5.9.8 \ mingw53_32 \ mkspecs \ modules directory

6. Use a compiled library, add the .pro file for the project

QT    +=   ftp

    #LIBS+="D:/.../Qt5.9.8/5.9.8/mingw53_32/bin/Qt5Ftp.dll"

http://2662597.blog.51cto.com/2652597/1279806

Guess you like

Origin blog.csdn.net/u013411873/article/details/92390288