Writing the code

Next, open up mainwindow.h and add the following headers:

#include <QMainWindow> 
#include <QDebug> 
#include <QNetworkAccessManager> 
#include <QNetworkRequest> 
#include <QNetworkReply> 
#include <QFile> 
#include <QFileInfo> 
#include <QFileDialog> 
#include <QListWidgetItem> 
#include <QMessageBox> 

After that, add in the following variables and functions:

private: 
   Ui::MainWindow *ui; 
   QNetworkAccessManager* manager; 
 
   QString ftpAddress; 
   int ftpPort; 
   QString username; 
   QString password; 
 
   QNetworkReply* downloadFileListReply; 
   QNetworkReply* uploadFileListReply; 
 
   QNetworkReply* uploadFileReply; 
   QNetworkReply* downloadFileReply; 
 
   QStringList fileList; 
   QString uploadFileName; 
   QString downloadFileName; public:   void getFileList();

Once you ...

Get Hands-On GUI Programming with C++ and Qt5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.