QDBusVariant 类

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

头: #include <QDBusVariant>
qmake: QT += dbus
Since: Qt 4.2

公共函数

QDBusVariant ()
QDBusVariant (const QVariant & variant )
QDBusVariant (QVariant && v )
void setVariant (const QVariant & variant )
void swap (QDBusVariant & other )
QVariant variant () const

详细描述

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");
    myDBusMessage.setArguments(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
    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 QDBusVariant is required to distinguish between a normal D-Bus value and a value within a D-Bus variant.

另请参阅 Qt D-Bus 类型系统 .

成员函数文档编制

QDBusVariant:: QDBusVariant ()

构造新的 D-Bus 变体。

QDBusVariant:: QDBusVariant (const QVariant & variant )

构造新的 D-Bus 变体从给定 Qt variant .

另请参阅 setVariant ().

QDBusVariant:: QDBusVariant ( QVariant && v )

Default constructs an instance of QDBusVariant.

void QDBusVariant:: setVariant (const QVariant & variant )

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

另请参阅 variant ().

void QDBusVariant:: swap ( QDBusVariant & other )

交换此 QDBusVariant 实例与 other .

QVariant QDBusVariant:: variant () const

将此 D-Bus 变体返回作为 QVariant 对象。

另请参阅 setVariant ().