Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How do I load all files in a resource directory in one method
Forum Updated to NodeBB v4.3 + New Features

How do I load all files in a resource directory in one method

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 826 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.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1

    I have a list of files and I couldn't be bothered to get all of their names and what I really want is to be able to load all of them into a canvas.

    1 Reply Last reply
    0
    • AxelViennaA Offline
      AxelViennaA Offline
      AxelVienna
      wrote on last edited by
      #2

      @AI_Messiah born three days ago and already posing questions...

      You may want to read about QDir::entryList()

      A resource directory is to be treated like any other directory, just with a ":" in front of the path.

      // Specify directory with leading ":"
      QDir myDir(":/yourResourceRoot/yourDir");
      
      // Specify selection criteria (empty list if you want all files)
      const QStringList sel = QStringList({"*.csv", "*.xlsx"}); 
      
      // read files (and ignore directories) that match selection criteria
      QStringList files = myDir.entryList(sel,QDir::Files);
      
      // iterate through file list
      foreach(QString filename, files)
      {
          // process individual file
      }
      

      C++ and Python walk into a bar. C++ reuses the first glass.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AI_Messiah
        wrote on last edited by
        #3

        @AxelVienna said in How do I load all files in a resource directory in one method:

        I thought there would be a way to do it in Javascript. I didn't expect to have to do it in C++.

        raven-worxR 1 Reply Last reply
        0
        • A AI_Messiah

          @AxelVienna said in How do I load all files in a resource directory in one method:

          I thought there would be a way to do it in Javascript. I didn't expect to have to do it in C++.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @AI_Messiah
          from QML-only via FolderListModel

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          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