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. QPointer, QSharedPointer and QWeakPointer - When it's perfect solution when it's not?

QPointer, QSharedPointer and QWeakPointer - When it's perfect solution when it's not?

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

    Hello!
    Just got curious about situation when using of QPointer, QSharedPointer or QWeakPointer is perfect solution and when it's not. Suggestions?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      QPointer when you want to observe QObject's lifetime.
      QSharedPointer when you share ownership of an object (last owner deletes the object)
      QWeakPointer when you want to observe lifetime of an object owned by shared pointers.

      B 1 Reply Last reply
      4
      • Chris KawaC Chris Kawa

        QPointer when you want to observe QObject's lifetime.
        QSharedPointer when you share ownership of an object (last owner deletes the object)
        QWeakPointer when you want to observe lifetime of an object owned by shared pointers.

        B Offline
        B Offline
        bogong
        wrote on last edited by bogong
        #3

        @Chris-Kawa Thx. Looks very similar to Objective-C pointers ... Issue closed.

        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