The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus typesystem. More...
| Header: | #include <QDBusVariant> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS DBus)target_link_libraries(mytarget PRIVATE Qt6::DBus) |
| qmake: | QT += dbus |
| QDBusVariant() | |
| QDBusVariant(const QVariant &variant) | |
| void | setVariant(const QVariant &variant) |
| void | swap(QDBusVariant &other) |
| QVariant | variant() const |
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 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.
[noexcept] QDBusVariant::QDBusVariant()Constructs a new D-Bus variant.
[explicit] QDBusVariant::QDBusVariant(const QVariant &variant)Constructs a new D-Bus variant from the given Qt variant.
See also setVariant().
Assigns the value of the given Qt variant to this D-Bus variant.
See also variant().
[noexcept] void QDBusVariant::swap(QDBusVariant &other)Swaps this variant with other. This operation is very fast and never fails.
Returns this D-Bus variant as a QVariant object.
See also setVariant().
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: