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

公共函数

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

详细说明

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

成员函数文档

[explicit] QVariantConstPointer::QVariantConstPointer(QVariant variant)

variant 构造一个 QVariantConstPointer。

QVariant QVariantConstPointer::operator*() const

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

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

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

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