介绍这个是因为它少用,但不是不好用,因此谈谈它,以免被遗忘,还有个同是一家亲的
QSharedPointer,还不了解,下次谈谈.
官方 Detailed DescriptionThe
QPointer class is a template class that provides guarded pointers to
QObjects.
A guarded pointer,
QPointer, behaves like a normal
C++ pointer T *, except that
itis automatically set to 0 when the referenced object is destroyed(unlike normal C++ pointers, which become “dangling pointers” in suchcases). T must be a subclass of
QObject.
Guarded pointers are useful whenever you need to store a pointer to a
QObject that is owned by someone else, and therefore might be destroyed while you still hold a reference to
it. You can safely test the pointer for valid
ity.
大体意思:
QPointer,像一个正常的c++的指针T*。当参考对象被摧毁,他是自动置零。T必须是
QObject的子类。
实例 ....
...
.
标签: it,
linux,
QObject,
QPointer,
QSharedPointer,
Qt 本文链接: QPointer 简单介绍 版权所有: Venus, 转载请注明来源Venus并保留链接地址!