Search code examples
c++boostqt5qfiledialog

How to save multiple images using QFileDialog and boost


I have small gui that has N.1 QGraphicsView and N.1 QPushButton. After I upload some images I am saving them in a specific folder on my Desktop. For this operation I am combining QFileDialog together with the library boost. Program runs but images are not being saved in the targeted folder, what am I missing?

See below the snipped of code I am using for the save QPushButton:

void MainWindow::on_saveToFileBtnCamB_clicked()
{
    QString rectB = QFileDialog::getExistingDirectory(this, tr("Choose an image directory to load"),
                                                     fileCamRectB, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
    boost::filesystem::path pb(rectB.toStdString());
    for(int i=0;i<finishedImages.size();i++)
    {
        finishedImages[i].getB().setSavePath(pb);
        finishedImages[i].getB().save();
        ui->progressBarSaveB->setValue(i);
    }
    dirB.setPath(rectB);
    ui->progressBarSaveB->setValue(finishedImages.size());
    finishedImages.clear();
}

Solution

  • Following my question the correct answer was the initial answer that Jarod42 gave, I was copying and paste wrong:

    finishedImages[i].getB().setSavePath(pb / ("imge_" + std::to_string(i) + ".extention");