Results 1 to 5 of 5

Thread: how select whole directory also in QFileDialog?

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default how select whole directory also in QFileDialog?

    How can i support QFileDialog to open multiple files and folders(Directories)?
    I'm wrote following code, It enables only to open files not able to open directories. How can i include Directory also?
    Qt Code:
    1. QStringList files = QFileDialog::getOpenFileNames(
    2. this,
    3. "Select one or more files to open",
    4. "/home",
    5. "Images (*.png *.xpm *.jpg)");
    To copy to clipboard, switch view to plain text mode 
    Please somebody help me....Thanks in advance..

  2. #2
    Join Date
    Oct 2011
    Posts
    19
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: how select whole directory also in QFileDialog?

    Qt Code:
    1. QString s = QFileDialog::getOpenFileName(
    2. "/home",
    3. "Images (*.png *.xpm *.jpg)",
    4. this,
    5. "open file dialog"
    6. "Choose a file" );
    To copy to clipboard, switch view to plain text mode 


    In the above example, The startup directory is set to "/home" ( or if you using windows -"C:\Win") The file filter is set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog is set to this and it is given the identification name - "open file dialog". The caption at the top of file dialog is set to "Choose a file". If you want to use multiple filters, separate each one with two semi-colons, e.g.
    "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"

    NOTE - The code given is a working code from Qt 3. I am not sure whether the funtion definition has changed Qt 3 to Qt 4. PLease check the man pages/ documentation.

    Hope this clear it out for you do let me/us know if you need anything more.

  3. #3
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how select whole directory also in QFileDialog?

    Quote Originally Posted by amitahire View Post
    Qt Code:
    1. QString s = QFileDialog::getOpenFileName(
    2. "/home",
    3. "Images (*.png *.xpm *.jpg)",
    4. this,
    5. "open file dialog"
    6. "Choose a file" );
    To copy to clipboard, switch view to plain text mode 


    In the above example, The startup directory is set to "/home" ( or if you using windows -"C:\Win") The file filter is set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog is set to this and it is given the identification name - "open file dialog". The caption at the top of file dialog is set to "Choose a file". If you want to use multiple filters, separate each one with two semi-colons, e.g.
    "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"

    NOTE - The code given is a working code from Qt 3. I am not sure whether the funtion definition has changed Qt 3 to Qt 4. PLease check the man pages/ documentation.

    Hope this clear it out for you do let me/us know if you need anything more.

    Thank u...But actual my requirement is the dialog must support opening both MULTIPLE FILES and DIRECTORY...
    If i use the code u given, where the list of file names(which is suppose to open) will be stored?

  4. #4
    Join Date
    Oct 2011
    Posts
    19
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: how select whole directory also in QFileDialog?

    Quote Originally Posted by aurora View Post
    Thank u...But actual my requirement is the dialog must support opening both MULTIPLE FILES and DIRECTORY...
    If i use the code u given, where the list of file names(which is suppose to open) will be stored?
    I searched around a bit and found that QFileDialog cannot by default select multiple files - http://developer.qt.nokia.com/faq/an...i_select_multi but by getting hold of other classes.

    Check these threads out

    http://www.qtcentre.org/threads/3422...le-directories

    http://www.qtcentre.org/threads/1881...om-QFileDialog

    Before posting search in the form first :-). Hope you can solve it.

  5. #5
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how select whole directory also in QFileDialog?

    Thank u so much...

Similar Threads

  1. QFileDialog to select files AND folders
    By superpacko in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2013, 12:59
  2. Replies: 8
    Last Post: 15th May 2012, 05:21
  3. QFileDialog select multiple directories
    By bepaald in forum Newbie
    Replies: 4
    Last Post: 15th May 2012, 05:17
  4. How to select folders from QFileDialog???
    By IndikaU in forum Newbie
    Replies: 4
    Last Post: 30th September 2011, 09:19
  5. Select multiple files from QFileDialog
    By jiveaxe in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2009, 14:57

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.