[PyQt] QtDBus: Calling a method with an Array of Strings signature with Python 3

Phil Thompson phil at riverbankcomputing.com
Tue Dec 6 17:56:09 GMT 2011


On Tue, 06 Dec 2011 17:43:36 +0000, Chris Mayo
<cjmayo at users.sourceforge.net> wrote:
> On 05/12/11 21:31, Phil Thompson wrote:
>> On Mon, 05 Dec 2011 19:12:33 +0000, Chris Mayo
>> <cjmayo at users.sourceforge.net>  wrote:
>>>>
>>>> Try this...
>>>>
>>>> arg = QDBusArgument()
>>>> arg.beginArray(QMetaType.QString)
>>>> arg.add("")
>>>> arg.endArray()
>>>>
>>>> ....and pass arg to call().
>>>
>>> Doesn't seem to work:
>>>
>>> device_iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
>>> 	'/org/freedesktop/UDisks/devices/sr0',
'org.freedesktop.UDisks.Device',
>>
>>> bus)
>>>
>>> arg = QtDBus.QDBusArgument()
>>> arg.beginArray(QMetaType.QString)
>>> arg.add("")
>>> arg.endArray()
>>>
>>> reply = device_iface.call("DriveEject", arg)
>>> print(reply.errorMessage())
>>>
>>>
>>> Returns:
>>>
>>> Unknown option
>>
>> ....because "" is not a valid option? According to...
>>
>> http://hal.freedesktop.org/docs/udisks/Device.html#Device.DriveEject
>>
>> ...."unmount" is the only valid option.
>>
>> Phil
> 
> Indeed it does work as:
> 
> arg = QtDBus.QDBusArgument()
> arg.beginArray(QMetaType.QString)
> arg.add("unmount")
> arg.endArray()
> 
> 
> and so does:
> 
> arg = QtDBus.QDBusArgument()
> arg.beginArray(QMetaType.QString)
> arg.endArray()
> 
> Experimenting with other calls shows this is the way to create an empty 
> Array of Strings.

The current snapshot also allows...

arg = QDBusArgument([], QMetaType.QStringList)

Phil


More information about the PyQt mailing list