Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Error on initializing QByteArray
Forum Updated to NodeBB v4.3 + New Features

Error on initializing QByteArray

Scheduled Pinned Locked Moved Unsolved Qt 6
7 Posts 3 Posters 851 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.
  • O Offline
    O Offline
    oliver_mpt
    wrote on last edited by
    #1

    Hi,

    I am porting an app from Qt 5.12.2 to Qt 6.5.0
    The following lines are generating a crash in Qt6 while they posed no problem in Qt5

    QByteArray qb;
    qb[0] = 0; qb[1] = 0;
    

    I have not found any indication in the documentation of the QByteArray class that its behaviour had been modified regarding this.

    Any idea ?

    SGaistS 1 Reply Last reply
    0
    • O oliver_mpt

      Hi,

      I am porting an app from Qt 5.12.2 to Qt 6.5.0
      The following lines are generating a crash in Qt6 while they posed no problem in Qt5

      QByteArray qb;
      qb[0] = 0; qb[1] = 0;
      

      I have not found any indication in the documentation of the QByteArray class that its behaviour had been modified regarding this.

      Any idea ?

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi,

      It's explained in the operator documentation for Qt 5.15. And the behavior for Qt 6 is also explained in the corresponding operator documentation.

      Your code will might already crash with 5.15.

      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
      1
      • O Offline
        O Offline
        oliver_mpt
        wrote on last edited by
        #3

        Hi SGaist

        Thanks for your help. Believe me, this code is working in 5.15.2 every day.
        I'll read the doc carefully

        Christian EhrlicherC SGaistS 2 Replies Last reply
        0
        • O oliver_mpt

          Hi SGaist

          Thanks for your help. Believe me, this code is working in 5.15.2 every day.
          I'll read the doc carefully

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

          @oliver_mpt said in Error on initializing QByteArray:

          Believe me, this code is working in 5.15.2 every day.

          But it may crash tomorrow since it's undefined behavior.

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

          1 Reply Last reply
          0
          • O oliver_mpt

            Hi SGaist

            Thanks for your help. Believe me, this code is working in 5.15.2 every day.
            I'll read the doc carefully

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @oliver_mpt my bad, wrong verb. I meant to write: might already crash. But luckily it's not.

            In any case, as the warning suggests, do not rely on such a behaviour.

            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
            0
            • O Offline
              O Offline
              oliver_mpt
              wrote on last edited by
              #6

              Thanks SGaist and Christian
              I'll rewrite that code cleanly :-)

              SGaistS 1 Reply Last reply
              0
              • O oliver_mpt

                Thanks SGaist and Christian
                I'll rewrite that code cleanly :-)

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You're welcome !

                Since you have the information you need, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum members may know a solution has been found :-)

                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
                0

                • Login

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