Uploading files to the FTP server

Since we don't have any files in our FTP directory yet (except the file list), let's write the code to allow us to upload our first file.

  1. First, open mainwindow.ui and right click on the Open button. Then, select Go to slot and select the clicked() option:
  1. A slot function will be automatically created for you. Then, add the following code to the function to open up the file selector window for our users to select their desired file for upload:
void MainWindow::on_openButton_clicked() 
{ 
   QString fileName = QFileDialog::getOpenFileName(this, "Select  File", qApp->applicationDirPath()); ui->uploadFileInput->setText(fileName); ...

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.