Qt 中的智能指针
就像它已经写的这里 Qt 到目前为止有 8 个专门的智能指针类。 看起来这就是您所需要的一切。 然而,为了使用任何这些智能指针,您的类必须从 QObject 派生,这并不总是很方便。 Qt 中是否还有其他可与任意类一起使用的智能指针实现?
Like it has been written here Qt up to now has 8 specilized smart pointer classes.
It looks like it is all you will ever need.
However, in order to use any of these smart pointers your class must be derived from QObject which is not always convenient.
Is there other implementations of smart pointers in Qt which work with arbitrary classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
许多 Qt 类都是从 QObject 派生的,虽然一些内置智能指针类与 QObject(或 QSharedData)相关,但 QSharedPointer 和 QScopedPointer< /a> 模板似乎允许指向任何内容的指针。
更“现代”的 C++(从 C++11 开始)具有有用的智能指针类型:https://stackoverflow.com/a/30143936 /33987。
除此之外,您还会发现一些智能指针模板 在 Boost 中:
Many Qt classes are derived from QObject, and while some of the built in smart pointer classes are related to QObject (or QSharedData), the QSharedPointer and QScopedPointer templates appear to allow pointers to anything.
More "modern" C++ (from C++11 onwards) has useful smart pointer types: https://stackoverflow.com/a/30143936/33987.
Beyond that, you'll find some smart pointer templates in Boost: