[PyQt] How to create an array of non-var struct with PyQt + QDBus?

Xinkai yeled.nova at gmail.com
Sun Oct 26 22:05:20 GMT 2014


Hi,

I am stuck with trying to create a QDBusMessage with an array of struct,
something like "a(ii)".  I tried the following on Python 3.4.2 + PyQt 5.3.2:


@pyqtSlot(QDBusMessage)
def process(self, msg):
    # Attempt 1
    a1 = QDBusArgument()
    a1.add(1, QMetaType.Int)
    a1.add(2, QMetaType.Int)

    a2 = QDBusArgument()
    a2.add(1, QMetaType.Int)
    a2.add(2, QMetaType.Int)

    reply = msg.createReply([
        [a1, a2],
    ])
    # Result: the signature is "av", not "a(ii)"


    # Attempt 2
    args = QDBusArgument()
    args.beginArray(??)

    args.endArray()
    # Result: No way to register a custom QMetaType. I understand there
might be a Qt type that happens to be int/int, but I am looking for a
more generic way to do this. I am actually dealing with something more
complex than "a(ii)".


Is there any way to do this? Or I hit the limitation of PyQt's QDBus, if
so, any suggestions?


Thanks in advance,

Xinkai




More information about the PyQt mailing list