本页内容

QVariantConstPointer Class

基于指针模拟的指向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 版本中被废弃。

公共函数

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 的常量指针,并符合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.