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. left versus leftRef
Forum Updated to NodeBB v4.3 + New Features

left versus leftRef

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 2.2k Views 4 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.
  • MucipM Offline
    MucipM Offline
    Mucip
    wrote on last edited by Mucip
    #1

    Hi,
    I just use Analyze tool on Win10 called "Clang-Tidy and Clazy" and I realized leftRef or midRef commands.

    Normaly I was using left or mid only. But Analyze gave report use midRef/leftRef instead of mid/left.

    I looked the documention and everything and the results are same both version.
    Well, what is the diffrerence of mid vs midRef or left vs.leftRef for Analyze tool?

    Regards,
    Mukcip:)

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

      Hi,

      No allocation in the case of the Ref version. They point directly on the QString content.

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

      MucipM 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        No allocation in the case of the Ref version. They point directly on the QString content.

        MucipM Offline
        MucipM Offline
        Mucip
        wrote on last edited by
        #3

        Hi @SGaist ,
        Ok. Thanks. This mean that Ref version doesn't need memory allocation?

        Regards,
        Mucip:)

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

          Only the thin wrapper QStringRef, not a full QString with the data copied in there.

          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
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            Note: QStringRef is deprecated in Qt 6. It is moved to a "Qt 5 compatibility" module and will be removed from Qt 7: https://doc-snapshots.qt.io/qt6-dev/qstringref.html

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

            MucipM 1 Reply Last reply
            2
            • JKSHJ JKSH

              Note: QStringRef is deprecated in Qt 6. It is moved to a "Qt 5 compatibility" module and will be removed from Qt 7: https://doc-snapshots.qt.io/qt6-dev/qstringref.html

              MucipM Offline
              MucipM Offline
              Mucip
              wrote on last edited by
              #6

              Hi @JKSH ,
              This is bad news. So I MUST NOT use ref versions? :(

              Regards,
              Mucip:)

              JKSHJ 1 Reply Last reply
              0
              • MucipM Mucip

                Hi @JKSH ,
                This is bad news. So I MUST NOT use ref versions? :(

                Regards,
                Mucip:)

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

                @Mucip said in left versus leftRef:

                So I MUST NOT use ref versions? :(

                Usually, there is no need to use the ref versions.

                What is your goal? Perhaps there are other ways to achieve your goal without using midRef()/leftRef()

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

                MucipM 1 Reply Last reply
                0
                • JKSHJ JKSH

                  @Mucip said in left versus leftRef:

                  So I MUST NOT use ref versions? :(

                  Usually, there is no need to use the ref versions.

                  What is your goal? Perhaps there are other ways to achieve your goal without using midRef()/leftRef()

                  MucipM Offline
                  MucipM Offline
                  Mucip
                  wrote on last edited by
                  #8

                  @JKSH said in left versus leftRef:

                  Usually, there is no need to use the ref versions.
                  What is your goal? Perhaps there are other ways to achieve your goal without using midRef()/leftRef()

                  As I said in my firs post. I already achieve my goal while using mid or left. But Analyzer suggest me to use Ref version.
                  Anyway. I can cancel "use Ref" suggestion. :)

                  Regards,
                  Mucip:)

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

                    You can already follow the new way by using QStringView like shown here.

                    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
                    • Pl45m4P Pl45m4 referenced this topic on

                    • Login

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