- Qt 6.11
- Qt Core
- C++ Classes
- QVariantPointer
- Qt 6.11.1 Reference Documentation

# QVariantPointer Class

template <typename Pointer> class QVariantPointer

QVariantPointer is a template class that emulates a pointer to QVariant based on a pointer. More...

Header: | `#include <QVariantPointer>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Core)` `target_link_libraries(mytarget PRIVATE Qt6::Core)`
qmake: | `QT += core`
Since: | Qt 6.0
Status: | Until 6.15

This class is scheduled for deprecation in version 6.15.

- List of all members, including inherited members

## Public Functions

| QVariantPointer(const Pointer *pointer)
QVariantRef<Pointer> | operator*() const
Pointer | operator->() const

## Detailed Description

Use QVariant::Pointer instead.

QVariantConstPointer wraps a pointer and returns QVariantRef to it from its operator*(). This makes it suitable as replacement for an actual pointer. We cannot return an actual pointer from generic iterators as the iterators don't hold an actual QVariant.

## Member Function Documentation

### `[explicit]` QVariantPointer::QVariantPointer(const Pointer *pointer)

Constructs a QVariantPointer from the given pointer.

### QVariantRef<Pointer> QVariantPointer::operator*() const

Dereferences the QVariantPointer to a QVariantRef.

### Pointer QVariantPointer::operator->() const

Dereferences and returns the pointer. The pointer is expected to also implement operator->().