本页内容

QVariant::Pointer Class

template <typename Indirect> class QVariant::Pointer

QVariant::Pointer 是一个模板类,用于模拟指向QVariant 的非const指针。更多内容...

该类于 Qt 6.11 中引入。

公共函数

Pointer(Indirect &&pointed)
Pointer(const Indirect &pointed)
operator QVariant::ConstPointer<Indirect>() const
QVariant::Reference<Indirect> operator*() const

详细说明

QVariant::Pointer<Indirect> 封装了一个类型为Indirect 的被指向值,并通过其 operator*() 返回一个指向该值的QVariant::Reference 。这使其适合作为实际指针的替代品。我们无法从泛型迭代器中返回实际指针,因为迭代器并不持有实际的QVariant 。

成员函数文档

[explicit noexcept(...)] Pointer::Pointer(Indirect &&pointed)

根据值pointed to 构造一个QVariant::Pointer 。

注意: 当std::is_nothrow_move_constructible_v<Indirect> 为true时,此 函数不满足 noexcept 要求。

[explicit noexcept(...)] Pointer::Pointer(const Indirect &pointed)

根据值pointed to 构造一个QVariant::Pointer 。

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

[noexcept(...)] Pointer::operator QVariant::ConstPointer<Indirect>() const

将此QVariant::Pointer 转换为QVariant::ConstPointer 。

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

[noexcept(...)] QVariant::Reference<Indirect> Pointer::operator*() const

将QVariant::Pointer 解引用为QVariant::Reference 。

注意: 当std::is_nothrow_copy_constructible_v<Indirect> 为true 时,此 函数为 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.