Results 1 to 13 of 13

Thread: QFileDialog filter

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question QFileDialog filter

    How to filter only execuatable files in Linux ?

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog filter

    Set following property before displaying file dialog.
    QFileDialog::setFilter(QDir::Executable)

  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: QFileDialog filter

    Not work. Is something wrong with my code ?

    Qt Code:
    1. open.setFilter(QDir::Executable);
    2. QString fileName = open.getOpenFileName(this, tr("Open Binary File"), QDir::homePath());
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFileDialog filter

    The Qt documentation says that QDir::Executable needs to be combined with QDir:: Dirs or QDir::Files.
    Read the docs about QFileDialog::setFilter(...)!

  5. #5
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: QFileDialog filter

    Qt Code:
    1. open.setFilter(QDir::Files | QDir::Executable);
    To copy to clipboard, switch view to plain text mode 

    Still not work
    Have any suggestion ?

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QFileDialog filter

    Does anything happen when setting the filter? Does any other filter work for you?
    It's nice to be important but it's more important to be nice.

  7. #7
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: QFileDialog filter

    Nothing
    And I don't know why...

  8. #8
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QFileDialog filter

    How do I set filter for retrieving list of files of type *.png AND *.jpg (or many more pic formats)?
    Qt 5.3 Opensource & Creator 3.1.2

  9. #9
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFileDialog filter

    Have a look at the "Detailed Description" of QFileDialog. There you will find an example for multiple filters.

  10. #10
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QFileDialog filter

    Quote Originally Posted by wirasto View Post
    Not work. Is something wrong with my code ?

    Qt Code:
    1. open.setFilter(QDir::Executable);
    2. QString fileName = open.getOpenFileName(this, tr("Open Binary File"), QDir::homePath());
    To copy to clipboard, switch view to plain text mode 
    Hi I'm also trying to do same kind of application. like openig a file dialog which should show only executable. But unfortunatly filter is not working. I did same way as above. Can any body tell how to solve it.
    I'm doing it in Linux.

    Thank you all.
    Last edited by sudhansu; 20th January 2010 at 08:09.

  11. #11
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QFileDialog filter

    Ok, now I see this post of yours with the same topic... It is because:
    QDir::Executable 0x040 List files for which the application has execute access. The Executable value needs to be combined with Dirs or Files.

  12. #12
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QFileDialog filter

    Quote Originally Posted by Lykurg View Post
    QDir::Executable 0x040 List files for which the application has execute access. The Executable value needs to be combined with Dirs or Files.
    Hi Lykurg, Can u plz tell me how to combined the Executable valus??

  13. #13
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QFileDialog filter

    You have to use the bit operators like | & ^ ~. E.g. use QDir::Files | QDir::Executable.

Similar Threads

  1. QFileDialog - will be closed after selecting a file
    By skyperhh in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 17:49
  2. QFileDialog and file sequences
    By peterhillman in forum Qt Programming
    Replies: 5
    Last Post: 24th November 2007, 11:16
  3. QFileDialog in Qt designer
    By tpf80 in forum Qt Tools
    Replies: 1
    Last Post: 17th May 2007, 01:41
  4. QFileDialog Mac / PC
    By hey in forum Qt Programming
    Replies: 3
    Last Post: 26th April 2007, 19:23
  5. Replies: 9
    Last Post: 5th March 2006, 04:31

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.