Results 1 to 4 of 4

Thread: QFileDialog custom acceptance condition

  1. #1
    Join Date
    Jun 2008
    Posts
    49
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QFileDialog custom acceptance condition

    I wonder how it is possible to set a custom acceptance condition for a QFileDialog.

    what I want to do is to have a dialog that would only accept directories that have a file of a certain name in them (say, a file named foo.bar). so when the QFileDialog is displayed, the Open button would only be enabled if the directory being selected matches the property of having a file named 'foo.bar' in it.

    I looked at the QFileDialog API, but did not find a way to add such a custom test.

    any pointers would be appreciated.

  2. #2
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFileDialog custom acceptance condition

    How about setNameFilter ?
    Sure, that way files not matching your filename wouldn't even be shown, but, from the users point of view, wouldn't it be better not to show files the user can't chose, instead of having him click around until he happens on such a file?

  3. #3
    Join Date
    Jun 2008
    Posts
    49
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog custom acceptance condition

    Quote Originally Posted by ChiliPalmer View Post
    How about setNameFilter ?
    Sure, that way files not matching your filename wouldn't even be shown, but, from the users point of view, wouldn't it be better not to show files the user can't chose, instead of having him click around until he happens on such a file?
    well, the problem comes from that I don't want to filter for the file name - I want to be able to select directories, which contain a specific file. the name of the directory is irrelevant.

  4. #4
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFileDialog custom acceptance condition

    Oh, I see. Have a look at this. You could use such a filter with your file dialog.

Similar Threads

  1. Using an If condition in a QML delegate?
    By technoViking in forum Qt Quick
    Replies: 8
    Last Post: 25th August 2011, 06:26
  2. How can i terminate a delay / wait condition
    By asinghma in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2011, 15:41
  3. Preview Thumbnail of images in Custom QFileDialog
    By toglia3d in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2010, 23:54
  4. Replies: 2
    Last Post: 30th June 2010, 11:48
  5. Sleep condition in QT
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 18th July 2008, 13:07

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.