Results 1 to 7 of 7

Thread: Select multiple files from QFileDialog

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Select multiple files from QFileDialog

    Hi,
    I need to open more than one file from a QFileDialog, but with the following code I can open only one file at a time:

    Qt Code:
    1. QFileDialog dialog(this);
    2. dialog.setDirectory(QDir::homePath());
    3. dialog.setFileMode(QFileDialog::ExistingFile);
    4. dialog.setNameFilter(trUtf8("Splits (*.000 *.001)"));
    5. QStringList fileNames;
    6. if (dialog.exec())
    7. fileNames = dialog.selectedFiles();
    To copy to clipboard, switch view to plain text mode 

    What I have missed?

    Thanks
    Giuseppe CalÃ

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Select multiple files from QFileDialog

    Take a closer look: QFileDialog::FileMode
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    Dong Back Kim (6th August 2011), jiveaxe (16th February 2009)

  4. #3
    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: Select multiple files from QFileDialog

    Qt Code:
    1. dialog.setFileMode(QFileDialog::ExistingFiles);
    To copy to clipboard, switch view to plain text mode 

  5. The following 2 users say thank you to Lykurg for this useful post:

    Dong Back Kim (6th August 2011), jiveaxe (16th February 2009)

  6. #4
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Select multiple files from QFileDialog

    Quote Originally Posted by Lykurg View Post
    Qt Code:
    1. dialog.setFileMode(QFileDialog::ExistingFiles);
    To copy to clipboard, switch view to plain text mode 
    Sorry Lykurg, but have you read my code? The line is still there.
    Giuseppe CalÃ

  7. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Select multiple files from QFileDialog

    Quote Originally Posted by jiveaxe View Post
    Sorry Lykurg, but have you read my code? The line is still there.
    Can you spot the difference?
    J-P Nurmi

  8. #6
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Select multiple files from QFileDialog

    brother, u have used QFileDialog::ExistingFile , while the correct one is QFileDialog::ExistingFiles ..

  9. #7
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Select multiple files from QFileDialog

    You are right
    Maybe I need a break

    Thanks
    Giuseppe CalÃ

Similar Threads

  1. QTableWidget - Select multiple rows.
    By wally in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2008, 17:15
  2. Multiple project files in a single directory
    By jogeshwarakundi in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 17th July 2008, 07:03
  3. Error: Using Multiple files
    By 3nc31 in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 09:23
  4. QFileDialog hidden files
    By blukske in forum Qt Programming
    Replies: 3
    Last Post: 8th March 2007, 02:11

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.