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. Select folder and upload all files from folder to server
Forum Updated to NodeBB v4.3 + New Features

Select folder and upload all files from folder to server

Scheduled Pinned Locked Moved Solved General and Desktop
28 Posts 5 Posters 9.3k Views 3 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.
  • D developerNancy
    5 May 2017, 08:46

    @koahnig I am using ubuntu I have already posted the code to upload file on server and for select the single file my code is void

      void MainWindow::selectFileDownload()
     {
    
         QString downloadlocation = QFileDialog::getOpenFileName();
        QDir dir = QFileInfo(downloadlocation).absoluteDir();
        qDebug() << dir;
        qDebug() << downloadlocation;
         this->downloadLine->setText(downloadlocation);
    

    }

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 5 May 2017, 08:50 last edited by
    #9

    @developerNancy There is no such constructor. Please check the documentation: http://doc.qt.io/qt-5.8/qdiriterator.html

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    D 1 Reply Last reply 5 May 2017, 09:50
    1
    • J jsulm
      5 May 2017, 08:50

      @developerNancy There is no such constructor. Please check the documentation: http://doc.qt.io/qt-5.8/qdiriterator.html

      D Offline
      D Offline
      developerNancy
      wrote on 5 May 2017, 09:50 last edited by
      #10

      @jsulm I have not Implemented directory yet it is a selected file method.

      D 1 Reply Last reply 5 May 2017, 10:24
      0
      • D developerNancy
        5 May 2017, 09:50

        @jsulm I have not Implemented directory yet it is a selected file method.

        D Offline
        D Offline
        developerNancy
        wrote on 5 May 2017, 10:24 last edited by
        #11

        @developerNancy
        Using this code
        QDirIterator UploadFolderFiles(UploadFolder, QDirIterator::Subdirectories );
        while (UploadFolderFiles.hasNext()) {
        qDebug() << UploadFolderFiles.next();
        }

        My output is this:
        /Desktop/testingQT"
        /Desktop/testingQT/Linuxapp"
        /Desktop/testingQT/.."
        /Desktop/testingQT/."
        /Desktop/testingQT/dfgdggd"

        But I want only files.

        M 1 Reply Last reply 5 May 2017, 10:48
        0
        • D developerNancy
          5 May 2017, 10:24

          @developerNancy
          Using this code
          QDirIterator UploadFolderFiles(UploadFolder, QDirIterator::Subdirectories );
          while (UploadFolderFiles.hasNext()) {
          qDebug() << UploadFolderFiles.next();
          }

          My output is this:
          /Desktop/testingQT"
          /Desktop/testingQT/Linuxapp"
          /Desktop/testingQT/.."
          /Desktop/testingQT/."
          /Desktop/testingQT/dfgdggd"

          But I want only files.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 5 May 2017, 10:48 last edited by
          #12

          @developerNancy

          well u left out the list of files u want
          so that seems to mean no files when u dont give it a list.

          D 2 Replies Last reply 5 May 2017, 10:54
          0
          • M mrjj
            5 May 2017, 10:48

            @developerNancy

            well u left out the list of files u want
            so that seems to mean no files when u dont give it a list.

            D Offline
            D Offline
            developerNancy
            wrote on 5 May 2017, 10:54 last edited by
            #13

            @mrjj My output is this:
            /Desktop/testingQT"
            /Desktop/testingQT/Linuxapp"
            /Desktop/testingQT/.."
            /Desktop/testingQT/."
            /Desktop/testingQT/dfgdggd"

            But there is . and .. also I want only files

            1 Reply Last reply
            0
            • M mrjj
              5 May 2017, 10:48

              @developerNancy

              well u left out the list of files u want
              so that seems to mean no files when u dont give it a list.

              D Offline
              D Offline
              developerNancy
              wrote on 5 May 2017, 11:47 last edited by
              #14

              @mrjj I want files only without . and .. means 1st is file name and second null and third also null and fourth is file name.

              /Desktop/testingQT/Linuxapp"
              /Desktop/testingQT/.."
              /Desktop/testingQT/."
              /Desktop/testingQT/dfgdggd"

              T 1 Reply Last reply 5 May 2017, 11:52
              0
              • D developerNancy
                5 May 2017, 11:47

                @mrjj I want files only without . and .. means 1st is file name and second null and third also null and fourth is file name.

                /Desktop/testingQT/Linuxapp"
                /Desktop/testingQT/.."
                /Desktop/testingQT/."
                /Desktop/testingQT/dfgdggd"

                T Offline
                T Offline
                the_
                wrote on 5 May 2017, 11:52 last edited by
                #15

                @developerNancy
                You may have a look at http://doc.qt.io/qt-5/qdiriterator.html#QDirIterator-2 and http://doc.qt.io/qt-5/qdir.html#Filter-enum

                -- No support in PM --

                D 1 Reply Last reply 5 May 2017, 11:53
                1
                • T the_
                  5 May 2017, 11:52

                  @developerNancy
                  You may have a look at http://doc.qt.io/qt-5/qdiriterator.html#QDirIterator-2 and http://doc.qt.io/qt-5/qdir.html#Filter-enum

                  D Offline
                  D Offline
                  developerNancy
                  wrote on 5 May 2017, 11:53 last edited by
                  #16

                  @the_ I am new in qt I don't know how to implement too confused

                  T 1 Reply Last reply 5 May 2017, 11:55
                  0
                  • D developerNancy
                    5 May 2017, 11:53

                    @the_ I am new in qt I don't know how to implement too confused

                    T Offline
                    T Offline
                    the_
                    wrote on 5 May 2017, 11:55 last edited by
                    #17

                    @developerNancy
                    Which part of the documentation don't you understand and what did you try so far?

                    -- No support in PM --

                    D 1 Reply Last reply 5 May 2017, 12:07
                    0
                    • T the_
                      5 May 2017, 11:55

                      @developerNancy
                      Which part of the documentation don't you understand and what did you try so far?

                      D Offline
                      D Offline
                      developerNancy
                      wrote on 5 May 2017, 12:07 last edited by
                      #18

                      @the_ I have almost done but I want only files......

                      T D 2 Replies Last reply 5 May 2017, 12:18
                      0
                      • D developerNancy
                        5 May 2017, 12:07

                        @the_ I have almost done but I want only files......

                        T Offline
                        T Offline
                        the_
                        wrote on 5 May 2017, 12:18 last edited by the_ 5 May 2017, 12:23
                        #19

                        @developerNancy

                        If you only want the files within a folder just apply the correct QDir::Filters to the QDirIterator.
                        Just a guess: QDir::Files as can be found in http://doc.qt.io/qt-5/qdir.html#Filter-enum

                        --EDIT

                        QDir::NoDotAndDotDot is not neccessary if you use QDir::Files as . and .. are folders and not files. my bad, sorry

                        -- No support in PM --

                        D 1 Reply Last reply 5 May 2017, 12:31
                        1
                        • D developerNancy
                          5 May 2017, 12:07

                          @the_ I have almost done but I want only files......

                          D Offline
                          D Offline
                          developerNancy
                          wrote on 5 May 2017, 12:19 last edited by
                          #20

                          @developerNancy Would be great if you could provide me with some working example of this.

                          Thanks

                          1 Reply Last reply
                          0
                          • T the_
                            5 May 2017, 12:18

                            @developerNancy

                            If you only want the files within a folder just apply the correct QDir::Filters to the QDirIterator.
                            Just a guess: QDir::Files as can be found in http://doc.qt.io/qt-5/qdir.html#Filter-enum

                            --EDIT

                            QDir::NoDotAndDotDot is not neccessary if you use QDir::Files as . and .. are folders and not files. my bad, sorry

                            D Offline
                            D Offline
                            developerNancy
                            wrote on 5 May 2017, 12:31 last edited by developerNancy 5 May 2017, 12:31
                            #21

                            @the_ said what I have to change

                                  QString UploadFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home",QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks);
                            
                              QDirIterator UploadFolderFiles(UploadFolder, QDirIterator::Subdirectories);
                                  while (UploadFolderFiles.hasNext()) {
                                      qDebug() << UploadFolderFiles.next();
                                  }
                             this->uploadLine->setText(UploadFolder);
                            
                            T 1 Reply Last reply 5 May 2017, 12:40
                            0
                            • D developerNancy
                              5 May 2017, 12:31

                              @the_ said what I have to change

                                    QString UploadFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home",QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks);
                              
                                QDirIterator UploadFolderFiles(UploadFolder, QDirIterator::Subdirectories);
                                    while (UploadFolderFiles.hasNext()) {
                                        qDebug() << UploadFolderFiles.next();
                                    }
                               this->uploadLine->setText(UploadFolder);
                              
                              T Offline
                              T Offline
                              the_
                              wrote on 5 May 2017, 12:40 last edited by
                              #22

                              @developerNancy

                              Just use QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags) instead of QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags = NoIteratorFlags) as your constructor and apply the filters you need as listed in QDir::Filters

                              -- No support in PM --

                              D 1 Reply Last reply 5 May 2017, 13:10
                              2
                              • T the_
                                5 May 2017, 12:40

                                @developerNancy

                                Just use QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags) instead of QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags = NoIteratorFlags) as your constructor and apply the filters you need as listed in QDir::Filters

                                D Offline
                                D Offline
                                developerNancy
                                wrote on 5 May 2017, 13:10 last edited by
                                #23

                                @the_ Thanks....

                                M 1 Reply Last reply 5 May 2017, 16:56
                                0
                                • D developerNancy
                                  5 May 2017, 13:10

                                  @the_ Thanks....

                                  M Offline
                                  M Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on 5 May 2017, 16:56 last edited by mrjj 5 May 2017, 16:57
                                  #24

                                  @developerNancy

                                  So in short, it is like first shown

                                  QDirIterator it(dir, QStringList() << "*.*", QDir::Files, QDirIterator::Subdirectories);
                                  

                                  The

                                  QStringList() << "*.*"
                                  

                                  tell what files you are after.

                                  If you dont tell it, it seems to think u say "i dont want any files" which makes sense.

                                  T 1 Reply Last reply 5 May 2017, 17:14
                                  2
                                  • M mrjj
                                    5 May 2017, 16:56

                                    @developerNancy

                                    So in short, it is like first shown

                                    QDirIterator it(dir, QStringList() << "*.*", QDir::Files, QDirIterator::Subdirectories);
                                    

                                    The

                                    QStringList() << "*.*"
                                    

                                    tell what files you are after.

                                    If you dont tell it, it seems to think u say "i dont want any files" which makes sense.

                                    T Offline
                                    T Offline
                                    the_
                                    wrote on 5 May 2017, 17:14 last edited by the_ 5 May 2017, 17:14
                                    #25

                                    @mrjj
                                    With the difference that *.* does only match files that contain a dot but misses all files without file extension ;)

                                    -- No support in PM --

                                    M 1 Reply Last reply 5 May 2017, 17:22
                                    2
                                    • T the_
                                      5 May 2017, 17:14

                                      @mrjj
                                      With the difference that *.* does only match files that contain a dot but misses all files without file extension ;)

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 5 May 2017, 17:22 last edited by mrjj 5 May 2017, 17:23
                                      #26

                                      @the_
                                      Good point
                                      But will
                                      "*"
                                      match all files , even on windows ?

                                      T 1 Reply Last reply 5 May 2017, 18:05
                                      2
                                      • M mrjj
                                        5 May 2017, 17:22

                                        @the_
                                        Good point
                                        But will
                                        "*"
                                        match all files , even on windows ?

                                        T Offline
                                        T Offline
                                        the_
                                        wrote on 5 May 2017, 18:05 last edited by
                                        #27

                                        @mrjj
                                        Not 100% sure if it matches all files but should do with all visible files.

                                        -- No support in PM --

                                        D 1 Reply Last reply 6 May 2017, 04:30
                                        2
                                        • T the_
                                          5 May 2017, 18:05

                                          @mrjj
                                          Not 100% sure if it matches all files but should do with all visible files.

                                          D Offline
                                          D Offline
                                          developerNancy
                                          wrote on 6 May 2017, 04:30 last edited by
                                          #28

                                          @the_ Its working using this QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags)

                                          1 Reply Last reply
                                          0

                                          18/28

                                          5 May 2017, 12:07

                                          • Login

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