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. QTextStream malfunction of read method
Forum Updated to NodeBB v4.3 + New Features

QTextStream malfunction of read method

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 467 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.
  • B Offline
    B Offline
    BartoszT
    wrote on last edited by
    #1

    My program reads QTextStream. It has 43kb. Correctly read data marked in green. The green ones were read in twos. Then the pink was read as one byte, and then the reading method skips one byte. I am expecting 0x0000, but gives me 0x00A4.
    When I change 0x0000 to (for example) 0x0102 in the source file, the read method works correctly.

    What is wrong?

    0_1560023734939_QT-read.png

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @BartoszT said in QTextStream malfunction of read method:

      What is wrong?

      You're trying to read a non-text file with QTextStream.

      Use QFile::read() or QFile::readAll() instead.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      JKSHJ 1 Reply Last reply
      4
      • Christian EhrlicherC Christian Ehrlicher

        @BartoszT said in QTextStream malfunction of read method:

        What is wrong?

        You're trying to read a non-text file with QTextStream.

        Use QFile::read() or QFile::readAll() instead.

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in QTextStream malfunction of read method:

        @BartoszT said in QTextStream malfunction of read method:

        What is wrong?

        You're trying to read a non-text file with QTextStream.

        Indeed. 0x0000 is not text, so QTextStream does not handle it.

        Use QFile::read() or QFile::readAll() instead.

        Agreed.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        3
        • B Offline
          B Offline
          BartoszT
          wrote on last edited by
          #4

          ... and what can I use instead of QString?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi and welcome to devnet,

            Since it's binary data, QByteArray.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            3

            • Login

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