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. Why QScopedPointer<QJsonArray> ?
Forum Updated to NodeBB v4.3 + New Features

Why QScopedPointer<QJsonArray> ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 303 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I'm working on a project that I did not create, there are two class members that I'm struggling to understand why they have been created this way?

    QScopedPointer<QJsonArray> exampleA;
    QScopedPointer<QJsonArray> exampleB;
    

    Yet above these there are also:

    QJsonArray exampleC;
    QJsonArray exampleD;
    

    The member names have just been made up by me for the purpose of this post. What is the benefit of using QScopedPointer with a class member?

    Kind Regards,
    Sy

    VRoninV 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I'm working on a project that I did not create, there are two class members that I'm struggling to understand why they have been created this way?

      QScopedPointer<QJsonArray> exampleA;
      QScopedPointer<QJsonArray> exampleB;
      

      Yet above these there are also:

      QJsonArray exampleC;
      QJsonArray exampleD;
      

      The member names have just been made up by me for the purpose of this post. What is the benefit of using QScopedPointer with a class member?

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      @SPlatten said in Why QScopedPointer<QJsonArray> ?:

      What is the benefit of using QScopedPointer with a class member?

      None, it's actually a tiny detriment to performance. The only use case I see is if you are std::moveing smart pointers created elsewhere into them but then again, Qt implicit sharing would have taken care of the issue without overheads just by passing-by-value

      "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

      SPlattenS 1 Reply Last reply
      2
      • VRoninV VRonin

        @SPlatten said in Why QScopedPointer<QJsonArray> ?:

        What is the benefit of using QScopedPointer with a class member?

        None, it's actually a tiny detriment to performance. The only use case I see is if you are std::moveing smart pointers created elsewhere into them but then again, Qt implicit sharing would have taken care of the issue without overheads just by passing-by-value

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @VRonin , thank you, thats what I thought, just thought it would be good to get a second opinion.

        Kind Regards,
        Sy

        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