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. Get QSharedPointer's Reference Count
Qt 6.11 is out! See what's new in the release blog

Get QSharedPointer's Reference Count

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.4k 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.
  • G Offline
    G Offline
    goocreations
    wrote on last edited by
    #1

    Is there any way I can retrieve the reference count for a QSharedPointer? If not what is the best way (if any) to implement a subclass of QSharedPointer that can return the reference count?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      You could reimplement your own reference counting mechanism around "QAtomicInt":http://qt-project.org/doc/qt-4.8/qatomicint.html.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goocreations
        wrote on last edited by
        #3

        Wow, cool. I was just implmeneting my own atomic int. Didn't know there was a class in Qt.

        So should I inherit from QSharedPointer and in every constructor and copy constructor increase the count; and then decrease the count in the desctructor?

        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