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. Where is the documentation for QByteRef?

Where is the documentation for QByteRef?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 2.0k 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.
  • A Offline
    A Offline
    aramaz
    wrote on last edited by
    #1

    Hello,

    I can't seem to find the documentation for QByteRef.
    I searched the documentation https://doc.qt.io/qt-5/search-results.html?q=qbyteref and nothing for QByteRef is shown.

    I also tried going through another documentation and click on QByteRef but it takes me to 404 Not found page.

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

      Hi,

      I would say a doc error.

      @Bonnie It's part of the public API so it's not internal.

      In any case, QByteRef is the equivalent of QStringRef but for 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
      2
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #2

        Seems there is no such doc.
        Think it as a Qt internal class.
        But you can find the full definition of the class in qbytearray.h.
        Maybe it is too simple to have a doc ;)

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

          Hi,

          I would say a doc error.

          @Bonnie It's part of the public API so it's not internal.

          In any case, QByteRef is the equivalent of QStringRef but for 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
          2
          • V Offline
            V Offline
            VTiTux
            wrote on last edited by VTiTux
            #4

            Still no documentation for QByteRef for Qt 5.15 in 2022?

            QByteRef is the return type of the QByteArray's methods back(), front(), and operator[], but the link are dead.
            Qt 6.x returns char&.

            It's not clear if QByteRef is a reference to a single byte, as bach/front/[] suggest, or if it is a reference to a bytes array, like QStringRef, as suggested by @SGaist.

            In the second case:
            I would like to share a byte array with two distinct read-only objects. What is the best: construct a QByteArray with 'fromRawData()' or using this QByteRef class?

            Christian EhrlicherC 1 Reply Last reply
            0
            • V VTiTux

              Still no documentation for QByteRef for Qt 5.15 in 2022?

              QByteRef is the return type of the QByteArray's methods back(), front(), and operator[], but the link are dead.
              Qt 6.x returns char&.

              It's not clear if QByteRef is a reference to a single byte, as bach/front/[] suggest, or if it is a reference to a bytes array, like QStringRef, as suggested by @SGaist.

              In the second case:
              I would like to share a byte array with two distinct read-only objects. What is the best: construct a QByteArray with 'fromRawData()' or using this QByteRef class?

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by Christian Ehrlicher
              #5

              @VTiTux said in Where is the documentation for QByteRef?:

              Still no documentation for QByteRef for Qt 5.15 in 2022?

              No, it's removed in Qt6 and I don't think anyone will add a documentation for this for Qt5 anymore but feel free to do so.

              /Edit: removed with 063e39df13dd53975d7d6615aa9f7e8429648aed in 2019 for Qt6

              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
              2
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                The QByteRef class has been removed in Qt 6 so don't use it all.

                QByteArray is a COW container so you don't need to do premature optimization.

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

                V 1 Reply Last reply
                2
                • SGaistS SGaist

                  The QByteRef class has been removed in Qt 6 so don't use it all.

                  QByteArray is a COW container so you don't need to do premature optimization.

                  V Offline
                  V Offline
                  VTiTux
                  wrote on last edited by
                  #7

                  Thank you, it is noted, I drop QByteRef.
                  @SGaist I have oversimplified my problem a bit. In fact, I have a large QByteArray, and I would like several others QByteArrays to reference subparts of this array, without copying the data. I don't think implicit sharing apply in this case.
                  QStringRef is a great class for that, for 16-bits QStrings (with .midRef(), LefRef(), and so on). QByteArray doesn't have this equivalent class. But 'fromRawData()' is a suitable solution.

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

                    In Qt6 you can use QByteArrayView

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

                    V 1 Reply Last reply
                    1
                    • Christian EhrlicherC Christian Ehrlicher

                      In Qt6 you can use QByteArrayView

                      V Offline
                      V Offline
                      VTiTux
                      wrote on last edited by
                      #9

                      @Christian-Ehrlicher Great, thank you!

                      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