Results 1 to 4 of 4

Thread: QFileDialog to select files AND folders

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    May 2012
    Posts
    4
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog to select files AND folders

    I tried to handle the same problem and I found a solution after searching in QT forums. The following is the codes that you could try:
    Qt Code:
    1. QFileDialog* _f_dlg = new QFileDialog(this);
    2. _f_dlg->setFileMode(QFileDialog::Directory);
    3. _f_dlg->setOption(QFileDialog::DontUseNativeDialog, true);
    4.  
    5. // Try to select multiple files and directories at the same time in QFileDialog
    6. QListView *l = _f_dlg->findChild<QListView*>("listView");
    7. if (l) {
    8. l->setSelectionMode(QAbstractItemView::MultiSelection);
    9. }
    10. QTreeView *t = _f_dlg->findChild<QTreeView*>();
    11. if (t) {
    12. t->setSelectionMode(QAbstractItemView::MultiSelection);
    13. }
    14.  
    15. int nMode = _f_dlg->exec();
    16. QStringList _fnames = _f_dlg->selectedFiles();
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to ijab for this useful post:

    superpacko (15th May 2012)

Similar Threads

  1. Replies: 8
    Last Post: 15th May 2012, 05:21
  2. Replies: 0
    Last Post: 11th February 2011, 04:48
  3. Qt select folders and files dialog.
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 13th July 2009, 08:53
  4. Select multiple files from QFileDialog
    By jiveaxe in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2009, 14:57
  5. Replies: 1
    Last Post: 5th October 2007, 09:51

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.