Results 1 to 2 of 2

Thread: Return value when cancelling QFileDialog::getOpenFileName()?

  1. #1
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Return value when cancelling QFileDialog::getOpenFileName()?

    Hi, all:

    I'm just wondering what is the return value when canceling QFileDialog::getOpenFileName() ????

    The typical example of how to use QFileDialog::getOpenFileName()
    can be found at http://pepper.troll.no/s60prerelease...iledialog.html

    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
    2. "/home",
    3. tr("Images (*.png *.xpm *.jpg)"));
    To copy to clipboard, switch view to plain text mode 


    It always return a value of type QString, no matter the user clicks "OK" or clicks "Cancel".

    When "cancel", what is the return value? I mean, what is the value of "fileName" when the QFileDialog has been canceled ??


    Best Regards
    JIA
    Welcome to Vision Open
    http://www.visionopen.com

  2. #2
    Join Date
    Feb 2010
    Location
    Finland
    Posts
    7
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Return value when cancelling QFileDialog::getOpenFileName()?

    Based on the documentation:

    This is a convenience static function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string.
    Was this what you were asking for?

  3. The following 2 users say thank you to viheaho for this useful post:

    Brusik (20th January 2011), jiapei100 (19th March 2010)

Similar Threads

  1. Why QFileDialog::getOpenFileName is not centered?
    By ricardo in forum Qt Programming
    Replies: 20
    Last Post: 30th August 2009, 23:08
  2. Replies: 2
    Last Post: 10th January 2008, 12:52
  3. Problem with QFileDialog::getOpenFileName()
    By spud in forum Qt Programming
    Replies: 4
    Last Post: 1st November 2007, 22:31
  4. Replies: 1
    Last Post: 14th October 2007, 23:10
  5. QFileDialog::getOpenFileName() gets stucked
    By elcuco in forum Qt Programming
    Replies: 5
    Last Post: 28th March 2006, 23:09

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.