Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt DBus: Byte type in QVariant, QVariantMap?



  • Hi, i am trying to implement the following DBus interface using Qt:

    void RegisterEndpoint(object endpoint, dict properties)
    possible properties:

    string UUID
    byte Codec
    array{byte} Capabilities
    

    This is currently described in XML the following way:

        <method name="RegisterEndpoint">
          <arg name="endpoint" type="o" direction="in"/>
          <arg name="properties" type="a{sv}" direction="in"/>
          <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
        </method>
    

    But when i call this method, i get an invalid arguments error.
    I guess, the reason is, because QVariant cannot take a Byte type (converting to int instead):

    properties	<3 items>	QVariantMap &
    	[0] "Capabilities"	"À\020\204\200ÿÿ"	
    		key	"Capabilities"	QString
    		value	"À\020\204\200ÿÿ"	QVariant (QByteArray)
    	[1] "Codec"	2	
    		key	"Codec"	QString
    		value	2	QVariant (int)
    	[2] "UUID"	"0000110b-0000-1000-8000-00805f9b34fb"	
    		key	"UUID"	QString
    		value	"0000110b-0000-1000-8000-00805f9b34fb"	QVariant (QString)
    

    Can anyone help out with suggestions to realize this?

    Many thanks in advance!



  • Solved: you have to create a QVariant like this:
    QVariant::fromValue(uchar(0)) -- instead of QVariant var = uchar(0);


Log in to reply