本页内容

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)
ConstReference(const QVariant::ConstReference<Indirect> &)
ConstReference(QVariant::ConstReference<Indirect> &&)
~ConstReference()
operator QVariant() const
QVariant::ConstReference<Indirect> &operator=(QVariant::ConstReference<Indirect> &&value)
QVariant::ConstReference<Indirect> &operator=(const QVariant::ConstReference<Indirect> &value)

详细说明

由于泛型迭代器实际上不会在每一步都实例化一个QVariant ,因此它们无法通过 operator*() 返回对该类的引用。QVariant::ConstReference<Indirect> 提供了与对QVariant 的实际引用相同的功能,但由类型为Indirect 的被引用值作为后端支持。 该模板针对 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`。

[implicit] 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(...) default] ConstReference::ConstReference(const QVariant::ConstReference<Indirect> &)

通过复制方式构造一个ConstReference 的实例。

注意: 当 `std::is_nothrow_copy_constructible_v<Indirect> ` 为 `true` 时,该 函数为 `noexcept`。

[delete] ConstReference::ConstReference(QVariant::ConstReference<Indirect> &&)

通过移动构造一个ConstReference 实例。该函数已被删除。

[default] ConstReference::~ConstReference()

销毁ConstReference 的实例。

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

解除对QVariant 的引用。此方法需要针对每种Indirect类型进行特化。 该方法已针对 QMetaSequence::ConstIterator、QMetaSequence::Iterator、QMetaAssociation::ConstIterator 和 QMetaAssociation::Iterator 预定义。

注意: 当Indirect::CanNoexceptConvertToQVariant 为true 时,此 函数为noexcept。

[delete] QVariant::ConstReference<Indirect> &ConstReference::operator=(QVariant::ConstReference<Indirect> &&value)

将value 按移动赋值的方式赋值给此ConstReference 实例。该函数已被删除。

[delete] QVariant::ConstReference<Indirect> &ConstReference::operator=(const QVariant::ConstReference<Indirect> &value)

将value 复制并赋值给该ConstReference 实例。此函数已被删除。

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