On this page

QVariant::ConstReference Class

template <typename Referred> class QVariant::ConstReference

The QVariant::ConstReference acts as a const reference to a QVariant. More...

This class was introduced in Qt 6.11.

Public Functions

ConstReference(Referred &&referred)
ConstReference(const Referred &referred)
QVariant operator QVariant() const

Detailed Description

As the generic iterators don't actually instantiate a QVariant on each step, they cannot return a reference to one from operator*(). QVariant::ConstReference provides the same functionality as an actual reference to a QVariant would, but is backed a referred-to value given as template parameter. The template is implemented for QMetaSequence::ConstIterator, QMetaSequence::Iterator, QMetaAssociation::ConstIterator, and QMetaAssociation::Iterator.

Member Function Documentation

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

Creates a QVariant::ConstReference from a referred.

Note: This function is noexcept when std::is_nothrow_move_constructible_v<Referred> is true.

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

Creates a QVariant::ConstReference from a referred.

Note: This function is noexcept when std::is_nothrow_copy_constructible_v<Referred> is true.

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

Dereferences the reference to a QVariant. This method needs to be specialized for each Referred type. It is pre-defined for QMetaSequence::ConstIterator, QMetaSequence::Iterator, QMetaAssociation::ConstIterator, and QMetaAssociation::Iterator.

Note: This function is noexcept when Referred::canNoexceptConvertToQVariant is true.

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