本页内容

QVariantRef Class

template <typename Pointer> class QVariantRef

QVariantRef 作为对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 版本中被废弃。

公共函数

QVariantRef(const Pointer *pointer)
QVariantRef(const QVariantRef<Pointer> &)
QVariantRef(QVariantRef<Pointer> &&)
~QVariantRef()
operator QVariant() const
QVariantRef<Pointer> &operator=(QVariantRef<Pointer> &&value)
QVariantRef<Pointer> &operator=(const QVariant &value)
QVariantRef<Pointer> &operator=(const QVariantRef<Pointer> &value)

详细说明

请改用QVariant::Reference 。

由于通用迭代器实际上不会在每个步骤上实例化一个 `QVariant `,因此它们无法通过 `operator*()` 返回对该类的引用。 QVariantRef 提供了与对QVariant 的实际引用相同的功能,但由类型为Pointer 的指针支持。该模板针对类型为 QSequentialIterator 和 QAssociativeIterator 的指针进行了实现。

成员函数文档

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

根据pointer 创建一个QVariantRef。

[default] QVariantRef::QVariantRef(const QVariantRef<Pointer> &)

复制并构造一个QVariantRef 实例。

[default] QVariantRef::QVariantRef(QVariantRef<Pointer> &&)

通过Move构造一个QVariantRef 的实例。

[default] QVariantRef::~QVariantRef()

销毁QVariantRef 的实例。

QVariantRef::operator QVariant() const

将QVariantRef 解析为实际的QVariant 。

QVariantRef<Pointer> &QVariantRef::operator=(QVariantRef<Pointer> &&value)

将一个新的value 赋值给指针thisQVariantRef 所指向的值。

QVariantRef<Pointer> &QVariantRef::operator=(const QVariant &value)

将一个新的value 赋值给指针this所指向的值QVariantRef 。

QVariantRef<Pointer> &QVariantRef::operator=(const QVariantRef<Pointer> &value)

将一个新的value 赋值给指针this所指向的值QVariantRef 。

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