PDA

View Full Version : QFileDialog::getSaveFileName Cancel Button



penny
8th April 2011, 16:07
I'm using QFileDialog::getSaveFileName to save a file.


QString saveFileName = QFileDialog::getSaveFileName(this,"Save As","./untitled.dat",tr("files(*.dat )"));
saveFile(saveFileName);
QMessageBox::StandardButton reply;
reply = QMessageBox::information(this, tr(" "), "File Saved");
I cannot understand how to recognize whether Save has been pressed or Cancel button. Currently my application saves the file even if i press cancel.

nightghost
8th April 2011, 16:46
The documentation for QFileDialog::getOpenFileName is more explicit.


If the user presses Cancel, it returns a null string.