Results 1 to 7 of 7

Thread: How to Display only external devices in QtFiledialog

  1. #1
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to Display only external devices in QtFiledialog

    Hi ,
    I want to use the QFileDialog to display only the external devices conencted to the linux system.If i use
    QFileDialog::getExistingDirectory(this,tr("File list"), QDir::currentPath());
    it lists the file system of the computer also. I want to filter it and just show the list of external devices connected to the system like any USB connected should be shown in the dialog.
    I tried using setFilter(QDir:rives); also but i read about this that Linux ignores this. So is there any way so that in file dialog i can display ONLY the USB/external devices connected? so that i don't show the entire file system of the computer.

  2. #2
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to Display only external devices in QtFiledialog

    I dont think it is possible with the standard QFileDialog. I'm not sure but I believe that this class uses standard Windows file dialog on Windows, standard Mac file dialog on Macs, something alike on Linux. So it's limited to whatever is provided by the OS.

    Most likely you will have to create your own dialog, or come up with a different solution.

  3. #3
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to Display only external devices in QtFiledialog

    But why QDir:: Drives doesn't work under linux?
    I think there should be some way of putting the filters etc to achieve this.

  4. #4
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to Display only external devices in QtFiledialog

    QDir:: Drives 0x004 List disk drives (ignored under Unix).
    Drives is a feature attributable to Windows only.

  5. #5
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to Display only external devices in QtFiledialog

    so there is no way out apart from creating a custom dialog of my own?

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Display only external devices in QtFiledialog

    On Windows, each drive has a letter, so you have C: D: E: etc. Under Linux you have no such system. A device such as a USB key can appear at any point of the file system.

    The best alternative you have is to parse the output of the 'df' command and create your own custom dialog, but it would be more intuitive to the user (and easier for you to code) to just show the entire file system and let them navigate themselves.

  7. #7
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to Display only external devices in QtFiledialog

    yes,you are right but i don't want user to play around with the terminal's file system. That was my idea. Also i don't know whether it is clear or not,i not only want to list the USB drives but also let the user browse through them,like normal file dialog.

Similar Threads

  1. External devices control
    By tiho_bg in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2009, 07:48
  2. Using QImage/QPixmap with external capture devices
    By schan117 in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2009, 10:30
  3. Vendor and Model Name from USB Devices
    By NoRulez in forum Qt Programming
    Replies: 6
    Last Post: 20th July 2009, 09:01
  4. Replies: 2
    Last Post: 14th January 2008, 18:09
  5. QtFileDialog: Mode Question!
    By Mokster in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2006, 21:41

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.