<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 10/27/2014 09:59 AM, Kovid Goyal
      wrote:<br>
    </div>
    <blockquote cite="mid:20141027015945.GU771@qedette" type="cite">
      <pre wrap="">I recommend you use the python DBUS bindings instead, they are more
capable than the PyQt ones, and generally nicer to use, since they dont
have to deal with the limitations of a C++ API. Another limitation of
the PyQt bindings is you cannot create properties that have non-basic
signatures.

See this <a class="moz-txt-link-freetext" href="http://qt-project.org/wiki/PySide_DBus_Integration">http://qt-project.org/wiki/PySide_DBus_Integration</a>
for a simple example of how to integrate the python dbus bindings with
the Qt event loop and see this: <a class="moz-txt-link-freetext" href="https://github.com/kovidgoyal/calibre/blob/master/src/calibre/gui2/sni.py">https://github.com/kovidgoyal/calibre/blob/master/src/calibre/gui2/sni.py</a>

for a more complex example, that includes properties/methods with
complex type signatures, and linking between Qt and DBUS signals.

Note that, to export properties, you will need a modified version of
dbus.service, which you can find here: 
<a class="moz-txt-link-freetext" href="https://github.com/kovidgoyal/calibre/blob/master/src/calibre/utils/dbus_service.py">https://github.com/kovidgoyal/calibre/blob/master/src/calibre/utils/dbus_service.py</a>

Remember to change is_py2 if you are running on python 3.

Kovid.

On Mon, Oct 27, 2014 at 06:05:20AM +0800, Xinkai wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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


_______________________________________________
PyQt mailing list    <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a>

!DSPAM:3,544d704918271087514679!


</pre>
      </blockquote>
      <br>
      <pre wrap="">_______________________________________________
PyQt mailing list    <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></pre>
    </blockquote>
    Thanks for the information about the dbus-python library.  However,
    I found the project page, it says: <i><font color="#003300">dbus-python
        might not be the best D-Bus binding for you to use. dbus-python
        does not follow the principle of "In the face of ambiguity,
        refuse the temptation to guess", and can't be changed to not do
        so without seriously breaking compatibility.</font></i><br>
    <br>
    That concered me, so I ended up writing a C++ extension with sip, to
    register QMetaType. It worked fine and I felt it was easy enough to
    do. <br>
    <br>
    Anyone having a similar problem can see my code at:
<a class="moz-txt-link-freetext" href="https://github.com/Xinkai/XwareDesktop/tree/master/src/frontend/Extensions">https://github.com/Xinkai/XwareDesktop/tree/master/src/frontend/Extensions</a><br>
    <br>
    <br>
    Cheers,<br>
    <br>
    Xinkai<i><br>
    </i><i></i><i> </i>
  </body>
</html>