MistyD
MistyD

Reputation: 17223

Need to save a new file with QFileDialog

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.

Upvotes: 6

Views: 15443

Answers (1)

Nemanja Boric
Nemanja Boric

Reputation: 22157

Use QFileDialog::getSaveFileName instead getOpenFileNames:

 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
                            "/home/jana/untitled.png",
                            tr("Images (*.png *.xpm *.jpg)"));

Upvotes: 13

Related Questions