Results 1 to 2 of 2

Thread: QFileDialog to only show executable files in Linux

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QFileDialog to only show executable files in Linux

    I have a QFileDialog that I want only to select executable files. Here is the code:

    Qt Code:
    1. QFileDialog selectFile(this,title);
    2. selectFile.setFilter(QDir::Files | QDir::Executable);
    3. selectFile.setDirectory(path);
    4. selectFile.setFileMode(QFileDialog::ExistingFile);
    5. if (selectFile.exec())
    6. qDebug() << selectFile.selectedFiles();
    To copy to clipboard, switch view to plain text mode 

    However I can see all files if I run it in Linux. Any idea how to correct it?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFileDialog to only show executable files in Linux

    This is interesting, different implementations bahve differently.

    With XDG_CURRENT_DESKTOP=KDE I get all files, as you do.

    When I run this with XDG_CURRENT_DESKTOP=GNOME I get no files at all.
    When I set the QFileDialog::Options to include DontUseNativeDialog I also get not files at all.

    I added QDir::Readable to the filter, now GNOME and Non-Native dialog show programs, but seem to not show scripts that are marked executable.

    Edit: ah, I think the two latter are actually the same thing (non-native dialog), just differently styled.

    Cheers,
    _

Similar Threads

  1. How to show version info by right clicking a Qt executable file in Linux?
    By TheIndependentAquarius in forum Installation and Deployment
    Replies: 2
    Last Post: 18th July 2014, 07:44
  2. Replies: 6
    Last Post: 9th May 2013, 15:44
  3. Replies: 3
    Last Post: 12th July 2010, 13:12
  4. Replies: 9
    Last Post: 28th April 2010, 09:18
  5. Run the executable also on linux
    By g_mandel in forum Installation and Deployment
    Replies: 1
    Last Post: 26th April 2010, 13:49

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.