[Qt-interest] How to use QFileDialog to save files?
Andre Somers
andre at familiesomers.nl
Mon May 31 07:02:03 CEST 2010
Op 31-5-2010 1:47, Rui Maciel schreef:
> I've used QFileDialog to select a file to write. Meanwhile, although it works great I haven't found
> a way to overwrite the dialog's labels so that they display text related to saving a file.
>
> This is how I've been using QFileDialog to save files
> <code>
> QFileDialog dialog(this);
> QStringList sl;
>
> // setup the file dialog
> dialog.setFileMode(QFileDialog::AnyFile);
> dialog.setNameFilter(tr("JSON document (*.json)"));
> dialog.setDefaultSuffix(".json");
> if(dialog.exec() == QDialog::Rejected)
> {
> // user cancelled
> return;
> }
> sl = dialog.selectedFiles();
>
> // snip boring file IO operations
> </code>
>
> So, how do you use QFileDialog to save files?
>
>
>
First of all, QFileDialog is not going to actually save the file for
you, it just returns a file name (including path) to use for that.
Did you see QFileDialog::acceptMode and ::setAcceptMode? Or did you take
a look at the static QFileDialog::getSaveFileName method?
André
More information about the Qt-interest-old
mailing list