在本页

QVariantConstPointer Class

基于指针的模拟常量指针,指向QVariant更多

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

该类计划在 6.15 版本中停用。

公共函数

QVariantConstPointer(QVariant variant)
QVariant operator*() const
const QVariant *operator->() const

详细说明

使用QVariant::ConstPointer 代替。

QVariantConstPointer 封装了一个QVariant ,并从其 operator*() 中返回。这使它适合替代实际的常量指针。我们不能从泛型迭代器中返回实际的常指针,因为迭代器并不持有实际的QVariant

成员函数文档

[explicit] QVariantConstPointer::QVariantConstPointer(QVariant variant)

variant 构造一个 QVariantConstPointer。

QVariant QVariantConstPointer::operator*() const

取消引用QVariantConstPointer ,以检索其内部QVariant

const QVariant *QVariantConstPointer::operator->() const

返回指向QVariant 的常量指针,符合操作符->() 的约定。

© 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.