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. How to make QFile read the whole line
Forum Updated to NodeBB v4.3 + New Features

How to make QFile read the whole line

Scheduled Pinned Locked Moved Unsolved General and Desktop
48 Posts 8 Posters 8.9k 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.
  • ManiRonM ManiRon

    @JonB

    No sir i checked the read by removing the NUL from the data in the file and i was able to see that it read the whole data and qDebug() was displaying the full data

    This is the whole data when i removed the NUL : " WQA.,?E>t1?dWQA.,DE_??n1?d7be1526df618c0c4d1bab3959adb65ada9f20bd969493e532a7861d29bc6e698{TB.)?V1??n1?dS[H21?z7_??n1?d340819615bcd7cb87459cac37070456eb0af53716c1f0064c4771857728d3777 "

    ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #19

    @ManiRon

    But when the data conatins NUL the data will be " WQA.,?E>t1?dWQA.,DE_??n1?d7be1526df618c0c4d1bab3959adb65ada9f20bd969493e532a7861d29bc6e698 "

    1 Reply Last reply
    0
    • ManiRonM ManiRon

      @VRonin but thsi doest read the full data

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #20

      @ManiRon said in How to make QFile read the whole line:

      but thsi doest read the full data

      What is the output of

      qDebug() << actualRead << size_of_file;
      

      ?

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

      ManiRonM 1 Reply Last reply
      0
      • jsulmJ jsulm

        @ManiRon said in How to make QFile read the whole line:

        but thsi doest read the full data

        What is the output of

        qDebug() << actualRead << size_of_file;
        

        ?

        ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on last edited by ManiRon
        #21

        @jsulm said in How to make QFile read the whole line:

        size_of_file

        Size = 194 .

        I thought it was qdebug problem so i wrote the data read from the file to another file then also it remains the same as the data shown in the debug

        ManiRonM 1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #22

          What is the value of actualRead?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          ManiRonM 1 Reply Last reply
          1
          • VRoninV VRonin

            What is the value of actualRead?

            ManiRonM Offline
            ManiRonM Offline
            ManiRon
            wrote on last edited by
            #23

            @VRonin

            Size = 194

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #24

              That means the read doesn't actually stop with the null

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              ManiRonM 1 Reply Last reply
              1
              • ManiRonM ManiRon

                @jsulm said in How to make QFile read the whole line:

                size_of_file

                Size = 194 .

                I thought it was qdebug problem so i wrote the data read from the file to another file then also it remains the same as the data shown in the debug

                ManiRonM Offline
                ManiRonM Offline
                ManiRon
                wrote on last edited by
                #25
                This post is deleted!
                1 Reply Last reply
                0
                • VRoninV VRonin

                  That means the read doesn't actually stop with the null

                  ManiRonM Offline
                  ManiRonM Offline
                  ManiRon
                  wrote on last edited by ManiRon
                  #26

                  @VRonin

                  Yes you are right sir, So what can we do ?

                  JonBJ 1 Reply Last reply
                  0
                  • ManiRonM ManiRon

                    @VRonin

                    Yes you are right sir, So what can we do ?

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #27

                    @ManiRon
                    "What can we do" about what? You've spent the whole time claiming the read stops at the NUL, now you confirm it does not, so what's the problem?

                    ManiRonM 2 Replies Last reply
                    1
                    • JonBJ JonB

                      @ManiRon
                      "What can we do" about what? You've spent the whole time claiming the read stops at the NUL, now you confirm it does not, so what's the problem?

                      ManiRonM Offline
                      ManiRonM Offline
                      ManiRon
                      wrote on last edited by
                      #28

                      @JonB

                      I am storing the data in QBytearray will that be a problem?

                      1 Reply Last reply
                      0
                      • JonBJ JonB

                        @ManiRon
                        "What can we do" about what? You've spent the whole time claiming the read stops at the NUL, now you confirm it does not, so what's the problem?

                        ManiRonM Offline
                        ManiRonM Offline
                        ManiRon
                        wrote on last edited by
                        #29

                        @JonB

                        the size it specifies is correct but the data displayed is till the NUL

                        JonBJ 1 Reply Last reply
                        0
                        • ManiRonM ManiRon

                          @JonB

                          the size it specifies is correct but the data displayed is till the NUL

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #30

                          @ManiRon said in How to make QFile read the whole line:

                          @JonB

                          the size it specifies is correct but the data displayed is till the NUL

                          But I said that was just how qDebug() displays data. Read up about how qDebug() displays strings/bytes, which may contain NUL.

                          ManiRonM 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @ManiRon said in How to make QFile read the whole line:

                            @JonB

                            the size it specifies is correct but the data displayed is till the NUL

                            But I said that was just how qDebug() displays data. Read up about how qDebug() displays strings/bytes, which may contain NUL.

                            ManiRonM Offline
                            ManiRonM Offline
                            ManiRon
                            wrote on last edited by
                            #31

                            @JonB

                            I have doubt in storing the data i store the data read in QBytearray

                            JonBJ 1 Reply Last reply
                            0
                            • ManiRonM ManiRon

                              @JonB

                              I have doubt in storing the data i store the data read in QBytearray

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by
                              #32

                              @ManiRon
                              So read up how qDebug() displays a QByteArray (as well as a QString)!!
                              Something even as old as https://www.qtcentre.org/threads/54236-qDebug-donsn-t-display-0x00?p=243053#post243053 will presumably do you.....

                              ManiRonM 1 Reply Last reply
                              2
                              • JonBJ JonB

                                @ManiRon
                                So read up how qDebug() displays a QByteArray (as well as a QString)!!
                                Something even as old as https://www.qtcentre.org/threads/54236-qDebug-donsn-t-display-0x00?p=243053#post243053 will presumably do you.....

                                ManiRonM Offline
                                ManiRonM Offline
                                ManiRon
                                wrote on last edited by ManiRon
                                #33

                                @JonB

                                Yes sir i can understand that it will take NUL as a terminate . Is there any way that i can store the full data along with the NUL

                                Christian EhrlicherC 1 Reply Last reply
                                0
                                • ManiRonM ManiRon

                                  @JonB

                                  Yes sir i can understand that it will take NUL as a terminate . Is there any way that i can store the full data along with the NUL

                                  Christian EhrlicherC Online
                                  Christian EhrlicherC Online
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #34

                                  @ManiRon said in How to make QFile read the whole line:

                                  Is there any way that i can store the full data along with the NUL

                                  It is stored, just qDebug() stops it's output when it sees NUL. Take a look at the link @JonB provided above.

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

                                  ManiRonM 1 Reply Last reply
                                  3
                                  • Christian EhrlicherC Christian Ehrlicher

                                    @ManiRon said in How to make QFile read the whole line:

                                    Is there any way that i can store the full data along with the NUL

                                    It is stored, just qDebug() stops it's output when it sees NUL. Take a look at the link @JonB provided above.

                                    ManiRonM Offline
                                    ManiRonM Offline
                                    ManiRon
                                    wrote on last edited by
                                    #35

                                    @Christian-Ehrlicher sir i checked the data are read from the file fully but the problem is the way i store . I tried to store it in a QByteArray variable, a char array Variable, a QString Variable but all are terminating when the data has a NUL Inbetween, Now its not the problem of qDebug .

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

                                      You really should try to understand what we wrote. When you QFile::read() returns exactly the size of the file then all bytes are read and stored in the QByteArray. Just because qDebug() stops at NUL doesn't mean there is no data after that...

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

                                      ManiRonM 1 Reply Last reply
                                      3
                                      • Christian EhrlicherC Christian Ehrlicher

                                        You really should try to understand what we wrote. When you QFile::read() returns exactly the size of the file then all bytes are read and stored in the QByteArray. Just because qDebug() stops at NUL doesn't mean there is no data after that...

                                        ManiRonM Offline
                                        ManiRonM Offline
                                        ManiRon
                                        wrote on last edited by ManiRon
                                        #37

                                        @Christian-Ehrlicher

                                        ok sir, But i tried to write the data what ever i stored in a QBytearray to another file and the result was same . Thats why i concluded that QByteArray terminate at NUL and its mentioned
                                        here
                                        http://doc.qt.io/qt-5/qbytearray.html#details

                                        J.HilkJ 1 Reply Last reply
                                        0
                                        • ManiRonM ManiRon

                                          @Christian-Ehrlicher

                                          ok sir, But i tried to write the data what ever i stored in a QBytearray to another file and the result was same . Thats why i concluded that QByteArray terminate at NUL and its mentioned
                                          here
                                          http://doc.qt.io/qt-5/qbytearray.html#details

                                          J.HilkJ Offline
                                          J.HilkJ Offline
                                          J.Hilk
                                          Moderators
                                          wrote on last edited by J.Hilk
                                          #38

                                          @ManiRon said in How to make QFile read the whole line:

                                          @Christian-Ehrlicher

                                          ok sir, But i tried to write the data what ever i stored in a QBytearray to another file and the result was same . Thats why i concluded that QByteArray terminate at NUL and its mentioned
                                          here
                                          http://doc.qt.io/qt-5/qbytearray.html#details

                                          where exactly ?
                                          because the docu clearly sates otherwise and, thats in the section you linked!

                                          ->
                                          0_1542352803222_1ca28d44-9917-4c44-89dc-0ae3b23ac891-image.png


                                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                          Q: What's that?
                                          A: It's blue light.
                                          Q: What does it do?
                                          A: It turns blue.

                                          ManiRonM 1 Reply Last reply
                                          2

                                          • Login

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