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. Read text file in array

Read text file in array

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.5k Views
  • 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.
  • P Offline
    P Offline
    prabhatjha
    wrote on last edited by
    #1

    hey i ahve a text file in which there are 3 coulmns ...i want to make array for each coulmn individually .
    how i can do this.i am adding my text file here https://drive.google.com/file/d/0BwR7_R9HuUvpa2R0WmlGZnVPbzg/edit?usp=sharing

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      Hi, first the file is not publicly available I think.
      If you want to read a file in QML you can either use a XMLHttpRequest (tutorial http://qmlbook.org/ch11/index.html#local-files) or in my opinion better way a c++ class where you ust use the default "QFile":http://qt-project.org/doc/qt-5/QFile.html to read the file and then process it in c++ and send the "array" back to QML.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prabhatjha
        wrote on last edited by
        #3

        Hey please check now ...you can access now this file.
        I am not using QML ...i am using QFile through this we can read all data of files.but there are three coulmn and i want to make array for each coulm individually.please suggest me some way how i can do this.

        1 Reply Last reply
        0
        • X Offline
          X Offline
          Xander84
          wrote on last edited by
          #4

          Hi, can you maybe give an example or function prototype how you would like to use it? It should be fairly easy to read that file in and split the columns.

          what i mean do you want a separate array for each column or a multidimensional array e.g.
          @
          // separate array for each column
          c1 = [1,2,3,...]
          c2 = [4,5,6,...]
          c3 = [7,8,9,...]
          // or multidimensional array
          a = [
          [1,2,3,...]
          [4,5,6,...]
          [7,8,9,...]
          ]
          @
          or something else?

          Also you know there is no way you can return multiple values with one return value, you could use callback function or "wrapper" like a std::tuple but then again you could just use a multidimensional array in the first place :D

          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