Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to save a new file with QFileDialog

Tags:

c++

qt

I am attempting to give the user an option of saving a file using QFileDialog However if the file does not exist the File Dialog states that the file does not exist. I want the QfileDialog to simply tell me the name of the file the user typed so that I can create it. I am doing the following

QFileDialog::getOpenFileNames(this, tr("Save File"))

and then create a file using the returned string.

like image 843
MistyD Avatar asked Sep 20 '13 15:09

MistyD


1 Answers

Use QFileDialog::getSaveFileName instead getOpenFileNames:

 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
                            "/home/jana/untitled.png",
                            tr("Images (*.png *.xpm *.jpg)"));
like image 196
Nemanja Boric Avatar answered Sep 24 '22 09:09

Nemanja Boric