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

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 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.
  • B Offline
    B Offline
    bogong
    wrote on 28 Jul 2020, 09:25 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
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 28 Jul 2020, 10:06 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 28 Jul 2020, 10:07
      4
      • C Chris Kawa
        28 Jul 2020, 10:06

        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 28 Jul 2020, 10:07 last edited by bogong
        #3

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

        1 Reply Last reply
        0

        1/3

        28 Jul 2020, 09:25

        • Login

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