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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.