QDBusVariant Class▲
-
Header: QDBusVariant
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Dbus)
target_link_libraries(mytarget PRIVATE Qt6::Dbus)
-
qmake: QT += dbus
Detailed Description▲
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&
lt;QVariant&
gt; arguments;
arguments &
lt;&
lt; QVariant(42
) &
lt;&
lt; QVariant::
fromValue(QDBusVariant(43
)) &
lt;&
lt; 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&
lt;QDBusVariant&
gt;(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▲
See also The Qt D-Bus Type System
Member Function Documentation▲
QDBusVariant::QDBusVariant()▲
Constructs a new D-Bus variant.
[explicit] QDBusVariant::QDBusVariant(const QVariant &variant)▲
void QDBusVariant::setVariant(const QVariant &variant)▲
void QDBusVariant::swap(QDBusVariant &other)▲
Swaps this QDBusVariant instance with other.