在本页

QVariant::ConstReference Class

template <typename Indirect> class QVariant::ConstReference

QVariant::ConstReference 充当QVariant 的常量引用 ... 更多...

该类在 Qt 6.11 中引入。

公共函数

ConstReference(Indirect &&referred)
ConstReference(QVariant::Reference<Indirect> &&nonConst)
ConstReference(const Indirect &referred)
ConstReference(const QVariant::Reference<Indirect> &nonConst)
operator QVariant() const

详细说明

由于泛型迭代器并不在每一步都实例化一个QVariant ,因此它们无法从 operator*() 返回一个引用。QVariant::ConstReference 提供的功能与实际引用QVariant 的功能相同,但它支持作为模板参数给出的引用值。该模板为 QMetaSequence::ConstIterator、QMetaSequence::Iterator、QMetaAssociation::ConstIterator 和 QMetaAssociation::Iterator 实现。

成员函数文档

[explicit noexcept(...)] ConstReference::ConstReference(Indirect &&referred)

referred 创建QVariant::ConstReference

注: std::is_nothrow_move_constructible_v<Indirect>true 时,此函数为 noexcept。

[default] ConstReference::ConstReference(QVariant::Reference<Indirect> &&nonConst)

nonConst 引用创建QVariant::ConstReference

[explicit noexcept(...)] ConstReference::ConstReference(const Indirect &referred)

referred 创建QVariant::ConstReference

注: std::is_nothrow_copy_constructible_v<Indirect>true 时,此函数为 noexcept。

[noexcept(...)] ConstReference::ConstReference(const QVariant::Reference<Indirect> &nonConst)

nonConst 引用创建QVariant::ConstReference

注: std::is_nothrow_copy_constructible_v<Indirect>true 时,此函数为 noexcept。

[noexcept(...)] ConstReference::operator QVariant() const

取消对QVariant 的引用。此方法需要为每种间接类型专门设计。它为 QMetaSequence::ConstIterator、QMetaSequence::Iterator、QMetaAssociation::ConstIterator 和 QMetaAssociation::Iterator 预先定义。

注意: Indirect::CanNoexceptConvertToQVarianttrue 时,此函数为 noexcept。

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