Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Get QSharedPointer's Reference Count

    General and Desktop
    qsharedpointer
    2
    4
    2081
    Loading More Posts
    • 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.
    • N
      Nishant Sharma last edited by

      Re: Get QSharedPointer's Reference Count

      Hi,
      Can someone share the code for getting the reference count using QSharedPointer?

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi
        There is no code to share as its not part of the public interface.
        The link talks about subclassing QSharedPointer to make the info
        available.

        Can I ask why you need this info ?

        Maybe something like
        http://doc.qt.io/qt-5/qshareddata.html#details
        http://doc.qt.io/qt-5/qshareddatapointer.html
        is better suited?

        1 Reply Last reply Reply Quote 0
        • N
          Nishant Sharma last edited by

          Hi,
          Thanks for your reply.
          The reason I ask this is that std::shared_ptr has a API for getting the reference count..
          And, for the purpose of understanding also, we need to know when the reference count was decreased, what made it decrease etc...

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Nishant Sharma last edited by

            @Nishant-Sharma
            Well if feel for it, you can add such info to the class yourself, maybe with extra debug information.
            or simply use std::shared_ptr

            Give it a day or two. I think other might have good idea regarding this :)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post