Results 1 to 5 of 5

Thread: How to make a file dialog with dirs only, multiselection and network places?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to make a file dialog with dirs only, multiselection and network places?

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication a(argc, argv);
    6. w.setFileMode(QFileDialog::DirectoryOnly);
    7. w.setOption(QFileDialog::DontUseNativeDialog,true);
    8. QListView *l = w.findChild<QListView*>("listView");
    9. if (l) {
    10. l->setSelectionMode(QAbstractItemView::MultiSelection);
    11. }
    12. QTreeView *t = w.findChild<QTreeView*>();
    13. if (t) {
    14. t->setSelectionMode(QAbstractItemView::MultiSelection);
    15. }
    16. return w.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 


    The following is the codes that you could try(The original link is http://www.qtcentre.org/threads/3422...108#post220108):

    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 
    Last edited by sonulohani; 1st August 2012 at 10:05.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

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

    tehman (1st August 2012)

Similar Threads

  1. Replies: 10
    Last Post: 28th January 2011, 08:50
  2. Replies: 0
    Last Post: 15th November 2009, 09:40
  3. My Network Places in QFileDialog
    By AlHadr in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2009, 15:38
  4. File Dialog / Network Protocols in QT4
    By themolecule in forum Qt Programming
    Replies: 6
    Last Post: 10th September 2007, 07:40
  5. Replies: 4
    Last Post: 12th April 2007, 19:52

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.