IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QDBusVariant Class

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

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

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

 
Sélectionnez
    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:

 
Sélectionnez
    // 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

Member Function Documentation

 

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

See also setVariant()

void QDBusVariant::setVariant(const QVariant &variant)

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

See Also

See also variant()

void QDBusVariant::swap(QDBusVariant &other)

Swaps this QDBusVariant instance with other.

QVariant QDBusVariant::variant() const

Returns this D-Bus variant as a QVariant object.

See Also

See also setVariant()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+