Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Smart Pointers: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(adds context on the existence of QPointer) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{LangSwitch}} | |||
[[Category:Developing_with_Qt::General]] | [[Category:Developing_with_Qt::General]] | ||
== Purpose == | == Purpose == | ||
A smart pointer is an abstract data type that has all features of a standard pointer and additionally provides automatic garbage collection. Smart pointers facilitate the dynamic memory operations. Their main advantage is reducing memory leaks and bugs due to poor memory management. | |||
== Smart Pointers in Qt == | == Smart Pointers in Qt == | ||
* | * {{DocLink|QSharedDataPointer}} | ||
* {{DocLink|QExplicitlySharedDataPointer}} | |||
* | |||
* QtPatternist::AutoPtr (internal class) | * QtPatternist::AutoPtr (internal class) | ||
* | * {{DocLink|QSharedPointer}} | ||
* | * {{DocLink|QWeakPointer}} | ||
* {{DocLink|QPointer}} since Qt5 a wrapper around QWeakPointer. The class was once planned to be deprecated but instead was kept to support legacy code. | |||
* QGuard (internal class) | * QGuard (internal class) | ||
* | * {{DocLink|QScopedPointer}} | ||
* {{DocLink|QScopedArrayPointer}} | |||
= See also = | == See also == | ||
* [http://blog.qt.io/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/ Count with me: how many smart pointer classes does Qt have?] | |||
* [http://www.macieira.org/blog/2012/07/continue-using-qpointer/ Continue using QPointer] | |||
= References = | == References == | ||
[http://en.wikipedia.org/wiki/Smart_pointers Smart Pointer] |
Latest revision as of 16:54, 3 November 2017
Purpose
A smart pointer is an abstract data type that has all features of a standard pointer and additionally provides automatic garbage collection. Smart pointers facilitate the dynamic memory operations. Their main advantage is reducing memory leaks and bugs due to poor memory management.
Smart Pointers in Qt
- QSharedDataPointer
- QExplicitlySharedDataPointer
- QtPatternist::AutoPtr (internal class)
- QSharedPointer
- QWeakPointer
- QPointer since Qt5 a wrapper around QWeakPointer. The class was once planned to be deprecated but instead was kept to support legacy code.
- QGuard (internal class)
- QScopedPointer
- QScopedArrayPointer