Auf dieser Seite

QDBusVariant Class

Die Klasse `QDBusVariant` ermöglicht es dem Programmierer, den vom D-Bus-Typsystem bereitgestellten Variantentyp zu identifizieren. Mehr...

Header: #include <QDBusVariant>
CMake: find_package(Qt6 REQUIRED COMPONENTS DBus)
target_link_libraries(mytarget PRIVATE Qt6::DBus)
qmake: QT += dbus

Öffentliche Funktionen

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

Ausführliche Beschreibung

Eine D-Bus-Funktion, die eine Ganzzahl, eine D-Bus-Variante und eine Zeichenkette als Parameter entgegennimmt, kann mit der folgenden Argumentliste aufgerufen werden (siehe QDBusMessage::setArguments()):

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

Wenn eine D-Bus-Funktion eine D-Bus-Variante zurückgibt, kann diese wie folgt abgerufen werden:

    // 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();

Die Funktion ` QVariant ` innerhalb einer `QDBusVariant` ist erforderlich, um zwischen einem normalen D-Bus-Wert und einem Wert innerhalb einer D-Bus-Varianten zu unterscheiden.

Siehe auch Das Typensystem von Qt D-Bus .

Dokumentation zu Mitgliedsfunktionen

[noexcept] QDBusVariant::QDBusVariant()

Erstellt eine neue D-Bus-Variante.

[explicit] QDBusVariant::QDBusVariant(const QVariant &variant)

variantErstellt eine neue Qt D-Bus-Variante aus dem angegebenen Qt XML-ph-0000@deepl.internal.

Siehe auch ` setVariant()`.

void QDBusVariant::setVariant(const QVariant &variant)

Weist dieser Qt D-Bus-Variante den Wert des angegebenen variant zu.

Siehe auch „ variant()“.

[noexcept] void QDBusVariant::swap(QDBusVariant &other)

Tauscht diese Variante gegen „ other “ aus. Dieser Vorgang ist sehr schnell und schlägt niemals fehl.

QVariant QDBusVariant::variant() const

Gibt diese D-Bus-Variante als „ QVariant “-Objekt zurück.

Siehe auch setVariant().

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