Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QDBusVariant Class Reference

\inmodule QtDBus More...

#include <qdbusextratypes.h>

+ Collaboration diagram for QDBusVariant:

Public Member Functions

 QDBusVariant () noexcept
 Constructs a new D-Bus variant.
 
 QDBusVariant (const QVariant &variant)
 Constructs a new D-Bus variant from the given Qt variant.
 
 QDBusVariant (QVariant &&v) noexcept
 
void swap (QDBusVariant &other) noexcept
 Swaps this QDBusVariant instance with other.
 
void setVariant (const QVariant &variant)
 Assigns the value of the given Qt variant to this D-Bus variant.
 
QVariant variant () const
 Returns this D-Bus variant as a QVariant object.
 

Detailed Description

\inmodule QtDBus

Since
4.2

The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus typesystem.

A D-Bus function that takes an integer, a D-Bus variant and a string as parameters can be called with the following argument list (see QDBusMessage::setArguments()):

myDBusMessage.setArguments(arguments);
QDBusVariant() noexcept
Constructs a new D-Bus variant.
Definition qlist.h:74
\inmodule QtCore
Definition qvariant.h:64
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
QList< QVariant > arguments

When a D-Bus function returns a D-Bus variant, it can be retrieved as follows:

// call a D-Bus function that returns a D-Bus variant
// retrieve the D-Bus variant
QDBusVariant dbusVariant = qvariant_cast<QDBusVariant>(v);
// retrieve the actual value stored in the D-Bus variant
QVariant result = dbusVariant.variant();
\inmodule QtDBus
QVariant variant() const
Returns this D-Bus variant as a QVariant object.
static QVariant callMyDBusFunction()
GLsizei const GLfloat * v
[13]
GLuint64EXT * result
[6]

The QVariant within a QDBusVariant is required to distinguish between a normal D-Bus value and a value within a D-Bus variant.

See also
{The Qt D-Bus Type System}

Definition at line 125 of file qdbusextratypes.h.

Constructor & Destructor Documentation

◆ QDBusVariant() [1/3]

QDBusVariant::QDBusVariant ( )
inlinenoexcept

Constructs a new D-Bus variant.

Definition at line 129 of file qdbusextratypes.h.

◆ QDBusVariant() [2/3]

QDBusVariant::QDBusVariant ( const QVariant variant)
inlineexplicit

Constructs a new D-Bus variant from the given Qt variant.

See also
setVariant()

Definition at line 145 of file qdbusextratypes.h.

◆ QDBusVariant() [3/3]

QDBusVariant::QDBusVariant ( QVariant &&  v)
inlineexplicitnoexcept

Definition at line 134 of file qdbusextratypes.h.

Member Function Documentation

◆ setVariant()

void QDBusVariant::setVariant ( const QVariant variant)
inline

Assigns the value of the given Qt variant to this D-Bus variant.

See also
variant()

Definition at line 148 of file qdbusextratypes.h.

◆ swap()

void QDBusVariant::swap ( QDBusVariant other)
inlinenoexcept

Swaps this QDBusVariant instance with other.

Definition at line 136 of file qdbusextratypes.h.

References other(), and QVariant::swap().

+ Here is the call graph for this function:

◆ variant()

QVariant QDBusVariant::variant ( ) const
inline

Returns this D-Bus variant as a QVariant object.

See also
setVariant()

Definition at line 140 of file qdbusextratypes.h.

Referenced by QXdgDesktopPortalTheme::QXdgDesktopPortalTheme(), main(), operator>>(), operator>>(), and QDBusAbstractInterfaceBase::qt_metacall().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: