本页内容

QVariantPointer Class

template <typename Pointer> class QVariantPointer

QVariantPointer 是一个模板类,它基于一个指针来模拟指向 `QVariant ` 的指针。更多内容...

头文件: #include <qvariant.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
自: Qt 6.0
状态: 直至 6.15

该类计划在 6.15 版本中被废弃。

公共函数

QVariantPointer(const Pointer *pointer)
QVariantRef<Pointer> operator*() const
Pointer operator->() const

详细说明

请改用QVariant::Pointer 。

QVariantPointer<Pointer> 封装了一个Pointer 类型的指针,并通过其 operator*() 向其返回QVariantRef 。这使其适合作为实际指针的替代品。由于泛型迭代器不持有实际的QVariant ,因此我们无法从泛型迭代器中返回实际指针。

成员函数文档

[explicit] QVariantPointer::QVariantPointer(const Pointer *pointer)

根据给定的pointer ,构建一个QVariantPointer。

QVariantRef<Pointer> QVariantPointer::operator*() const

将QVariantPointer 解引用为QVariantRef 。

Pointer QVariantPointer::operator->() const

对指针进行解引用并返回该指针。该指针还应实现 operator->() 运算符。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.