Solved Cannot send uchar via D-Bus because there is no QVariant constructor from type uchar
-
Hello,
I'm using Qt 5.8 and D-Bus.
I need to call from my Qt application the D-Bus interface of a non-Qt application. One of the expected arguments is a uchar. According to page https://doc.qt.io/qt-5/qdbustypesystem.html, "The primitive types are supported natively by QDBusArgument and need no special customization to be sent or received".
I'd like to know how I can call method
QDBusAbstractInterface::asyncCallWithArgumentList(const QString & method, const QList<QVariant> & args)
with uchar types as argument. The arguments need to be wrapped into a QVariant.
Problem: there is no QVariant constructor from type uchar, only QChar.
Consequence:
- if I call method QDBusAbstractInterface::asyncCallWithArgumentList with a uchar argument, it will be wrapped into a QVariant int
- if I call method QDBusAbstractInterface::asyncCallWithArgumentList with a QChar argument, it will be wrapped into a QVariant Qchar but QChar is not registered on D-Bus so I need to register it and define a marshmaller, which implies creating a custom D-Bus object that consists in a structure containing a byte, which is different from a simple byte
NB: same issue if I want to pass a short argument.
Many thanks in advance,
Cheers,
Cécile -
You can use
QVariant::fromValue(const T &value)
-
@Bonnie said in Cannot send uchar via D-Bus because there is no QVariant constructor from type uchar:
QVariant::fromValue(const T &value)
Hi Bonnie, I just tested and it writes a dbus.Byte indeed, many thanks for your help!