Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. is there any way to get multiple Dirs using getexistingdirectory ?
Forum Updated to NodeBB v4.3 + New Features

is there any way to get multiple Dirs using getexistingdirectory ?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by opengpu2
    #1

    is there any way to get multiple Dirs using getexistingdirectory ??

    1 Reply Last reply
    0
    • sneubertS Offline
      sneubertS Offline
      sneubert
      wrote on last edited by
      #2

      just a guess, but maybe you can use some kind ofsetFilter(QDir::Dirs) and selectedUrls() or selectedFiles()

      O 1 Reply Last reply
      0
      • sneubertS sneubert

        just a guess, but maybe you can use some kind ofsetFilter(QDir::Dirs) and selectedUrls() or selectedFiles()

        O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        @sneubert getexistingdirectory or getopenfilenames is static API

        sneubertS 1 Reply Last reply
        0
        • O opengpu2

          @sneubert getexistingdirectory or getopenfilenames is static API

          sneubertS Offline
          sneubertS Offline
          sneubert
          wrote on last edited by
          #4

          @opengpu2

          sorry, if you cant create an object of QFileDialog, I think it´s not possible

          O 1 Reply Last reply
          0
          • sneubertS sneubert

            @opengpu2

            sorry, if you cant create an object of QFileDialog, I think it´s not possible

            O Offline
            O Offline
            opengpu2
            wrote on last edited by
            #5

            @sneubert
            @QFileDialog* _f_dlg = new QFileDialog(this);
            _f_dlg->setFileMode(QFileDialog::Directory);
            _f_dlg->setOption(QFileDialog::DontUseNativeDialog, true);

            // Try to select multiple files and directories at the same time in QFileDialog
            QListView l = _f_dlg->findChild<QListView>("listView");
            if (l) {
            l->setSelectionMode(QAbstractItemView::MultiSelection);
            }
            QTreeView t = _f_dlg->findChild<QTreeView>();
            if (t) {
            t->setSelectionMode(QAbstractItemView::MultiSelection);
            }

            int nMode = _f_dlg->exec();
            QStringList _fnames = _f_dlg->selectedFiles();@

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kantharaj
              wrote on last edited by Kantharaj
              #6

              Try this you can select/Deselect the directories. since native directory file browser won't support the multiple directory selection, need to set the flags DontUseNativeDialog, its exactly what @opengpu2 has said.

              QFileDialog w;
              w.setFileMode(QFileDialog::DirectoryOnly);
              w.setOption(QFileDialog::DontUseNativeDialog,true);
              QListView *lView = w.findChild<QListView*>("listView");
              if (lView)
                  lView->setSelectionMode(QAbstractItemView::MultiSelection);
              QTreeView *tView = w.findChild<QTreeView*>();
              if (tView)
                  tView->setSelectionMode(QAbstractItemView::MultiSelection);
              w.exec();
              qDebug() << " Selected Directories :  " << w.selectedFiles();
              
              1 Reply Last reply
              0
              • O Offline
                O Offline
                opengpu2
                wrote on last edited by opengpu2
                #7

                selectedFiles can return the selected Dirs and Files....
                but these are in QStringList....how can i distinguish the dir from the files?
                thank you!

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved