Results 1 to 2 of 2

Thread: QFileDialog::getSaveFileName Cancel Button

  1. #1
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default QFileDialog::getSaveFileName Cancel Button

    I'm using QFileDialog::getSaveFileName to save a file.

    Qt Code:
    1. QString saveFileName = QFileDialog::getSaveFileName(this,"Save As","./untitled.dat",tr("files(*.dat )"));
    2. saveFile(saveFileName);
    3. QMessageBox::StandardButton reply;
    4. reply = QMessageBox::information(this, tr(" "), "File Saved");
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog::getSaveFileName Cancel Button

    The documentation for QFileDialog::getOpenFileName is more explicit.

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

  3. The following user says thank you to nightghost for this useful post:

    penny (9th April 2011)

Similar Threads

  1. QFileDialog::getSaveFileName Save Button
    By penny in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2011, 08:55
  2. QInputDialog like QFileDialog::getSaveFileName
    By BIllNo123 in forum Newbie
    Replies: 5
    Last Post: 23rd September 2010, 14:51
  3. problem with QFileDialog::getSaveFileName
    By navi1084 in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2009, 07:38
  4. Processo Ok or Cancel in a QFileDialog
    By gt.beta2 in forum Newbie
    Replies: 8
    Last Post: 20th February 2009, 17:53
  5. A question about QFileDialog::getSaveFileName
    By Ali in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 19:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.