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. get a QList<QUrl> from folder
Forum Updated to NodeBB v4.3 + New Features

get a QList<QUrl> from folder

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 954 Views 1 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.
  • N Offline
    N Offline
    NguyenMinh
    wrote on 19 Jun 2019, 10:10 last edited by
    #1

    Hello,
    I'm trying to get a list url of the mp3 file from a folder.
    I have tried

    urlList=QFileDialog::getOpenFileUrls(nullptr,QString(),temp,"*.mp3",nullptr,QFileDialog::ShowDirsOnly);
    

    but it still let me chose file instead of folder.
    Is there any other way to do what I want?

    J 1 Reply Last reply 19 Jun 2019, 10:24
    0
    • N NguyenMinh
      19 Jun 2019, 10:10

      Hello,
      I'm trying to get a list url of the mp3 file from a folder.
      I have tried

      urlList=QFileDialog::getOpenFileUrls(nullptr,QString(),temp,"*.mp3",nullptr,QFileDialog::ShowDirsOnly);
      

      but it still let me chose file instead of folder.
      Is there any other way to do what I want?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 19 Jun 2019, 10:24 last edited by jsulm
      #2

      @NguyenMinh said in get a QList<QUrl> from folder:

      but it still let me chose file instead of folder

      Isn't that what you want to do: get a list of mp3 files? Or do you mean it lets you select directories?
      If you want to select directory use https://doc.qt.io/qt-5/qfiledialog.html#getExistingDirectoryUrl

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

      N 1 Reply Last reply 19 Jun 2019, 10:31
      3
      • J jsulm
        19 Jun 2019, 10:24

        @NguyenMinh said in get a QList<QUrl> from folder:

        but it still let me chose file instead of folder

        Isn't that what you want to do: get a list of mp3 files? Or do you mean it lets you select directories?
        If you want to select directory use https://doc.qt.io/qt-5/qfiledialog.html#getExistingDirectoryUrl

        N Offline
        N Offline
        NguyenMinh
        wrote on 19 Jun 2019, 10:31 last edited by
        #3

        @jsulm but I want to chose folder and get QList<QUrl> of all mp3 file in that folder

        getExistingDirectoryUrl only return a QUrl of that folder

        J P 2 Replies Last reply 19 Jun 2019, 10:35
        0
        • N NguyenMinh
          19 Jun 2019, 10:31

          @jsulm but I want to chose folder and get QList<QUrl> of all mp3 file in that folder

          getExistingDirectoryUrl only return a QUrl of that folder

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 19 Jun 2019, 10:35 last edited by jsulm
          #4

          @NguyenMinh I really don't understand the problem: getOpenFileUrls opens a file dialog where you can navigate through all your directories and select files.
          If you want to select a directory when opening the dialog then take a look at documentation: https://doc.qt.io/qt-5/qfiledialog.html#getOpenFileUrls - there is dir parameter for that.
          If you want to know which directory user selected simply check the path of the first returned file URL - it will contain the whole path including the directory.

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

          1 Reply Last reply
          3
          • N NguyenMinh
            19 Jun 2019, 10:31

            @jsulm but I want to chose folder and get QList<QUrl> of all mp3 file in that folder

            getExistingDirectoryUrl only return a QUrl of that folder

            P Offline
            P Offline
            Pl45m4
            wrote on 19 Jun 2019, 10:51 last edited by
            #5

            @NguyenMinh

            EntryInfo together with a *.mp3 Filter should do the job.
            You can convert the absolute paths to QUrl, if you need to.


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            2

            1/5

            19 Jun 2019, 10:10

            • Login

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