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. Multiple QTextStreams use readline to read the same QFile, and the obtained QString is empty
Forum Updated to NodeBB v4.3 + New Features

Multiple QTextStreams use readline to read the same QFile, and the obtained QString is empty

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 168 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.
  • K Offline
    K Offline
    Kerry_Wu
    wrote on last edited by
    #1

    I use QFile to open a csv file stored locally in xlsx. In the way of QIODevice::ReadOnly | QIODevice::Text, then define a QTextStream object, use readline to read four lines of data, each time the pos() of the file is 24, 51, 78, 105, because the first line has Chinese, so it is different from the incremented value later, but immediately after defining the second QTextStream object, the value returned by pos after using readline is 37, and then defining another one, the same operation, the returned value is 22, my data is basically this Kind of "2021/11/17,11:01:15,41,1,", if many QTextStream objects are defined, the data read will appear empty

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Well then don't define multiple text streams, right? Each operation on a file will move the current position in the QFile object, so from that perspective what you describe seems OK. Maybe share the relevant piece of code and we'll be able to help then.

      (Z(:^

      1 Reply Last reply
      5

      • Login

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