QDBusVariant Class

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

Header: #include <QDBusVariant>
Since: Qt 4.2
Inherits: QVariant (private)

Public Functions

QDBusVariant(const QVariant & variant)
void setVariant(const QVariant & variant)
QVariant variant() const
  • 47 public functions inherited from QVariant

Additional Inherited Members

  • 3 static public members inherited from QVariant

Detailed Description

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()):

    QList<QVariant> arguments;
    arguments << QVariant(42) << QVariant::fromValue(QDBusVariant(43)) << QVariant("hello");

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
    QVariant v = callMyDBusFunction();
    // 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();

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 QtDBus type system.

Member Function Documentation


Constructs a new D-Bus variant.

QDBusVariant::QDBusVariant(const QVariant & variant)

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

See also setVariant().

void QDBusVariant::setVariant(const QVariant & variant)

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

See also variant().

QVariant QDBusVariant::variant() const

Returns this D-Bus variant as a QVariant object.

See also setVariant().

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