[Qt-interest] How to use QFileDialog to save files?

Rui Maciel rui.maciel at gmail.com
Mon May 31 01:47:08 CEST 2010


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?


Thanks in advance,
Rui Maciel



More information about the Qt-interest-old mailing list