mercredi 19 décembre 2018

QFileDIalog not working properly when setting an arbitrary destination folder

I am trying to save files setting a destination folder. I would like the user to be able to decide to which folder save the images but for some reasons QFileDialog is sending the images on Desktop despite a specific folder has been chosen.

Below the snipped of code I am using to save the files:

mainwindow.h

private:
    QString loadedDirectorySaved;

mainwindow.cpp

void MainWindow::on_saveCropsImgsBtn_clicked()
{
    QString dirName = QFileDialog::getExistingDirectory(this, tr("Save cropped images"),
                                       loadedDirectorySaved, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
    if(dirName != QString(""))
    {
     loadedDirectorySaved = dirName;
     ui->savedCropsLabelA->setText("Cropped images are currently saved in" + dirName);
    }
    else return;
}

So to quickly recap: instead of saving the files into /home/emanuele/Desktop/crops the images are stored in /home/emanuele/Desktop Thanks for pointing in the right direction.

Aucun commentaire:

Enregistrer un commentaire