Results 1 to 3 of 3

Thread: Working with QDBus and custom types

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Unhappy Working with QDBus and custom types

    Hi all,

    I'm trying to get a small Qt apps working with DBus but there are some details I cannot find anywhere (perhaps I'm not looking after the right key words...)

    1st.
    In my app.h, I declare a structure:
    Qt Code:
    1. typedef struct s_MyStruct{
    2. int i;
    3. } MyStruct;
    To copy to clipboard, switch view to plain text mode 

    and I use it in a slot:

    Qt Code:
    1. public Q_SLOTS:
    2. QString sayHelloWorld(MyStruct arg);
    To copy to clipboard, switch view to plain text mode 

    But when I use qdbuscpp2xml to generate the xml dbus interface of this application/service, this method using a structure does not appear whereas DBus has a structure type.

    I found that I can add this by hand like this:
    Qt Code:
    1. <method name="sayHelloWorld">
    2. <arg type="s" direction="out"/>
    3. <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MyStruct"/>
    4. <arg name="c" type="(si)" direction="in"/>
    To copy to clipboard, switch view to plain text mode 

    I did not find any doc on Trolltech website for this so, where all of this is documented ?


    2nd.
    My second problem is when I'm trying to compile my application.
    - I defined my structure to Qt MetaType with the macro:
    Qt Code:
    1. Q_DECLARE_METATYPE(MyStruct)
    To copy to clipboard, switch view to plain text mode 
    - I defined the
    Qt Code:
    1. QDBusArgument &operator<<(QDBusArgument &argument, const MyStruct &arg);
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. const QDBusArgument &operator>>(const QDBusArgument &argument, MyStruct &arg);
    To copy to clipboard, switch view to plain text mode 
    operators
    - BUT when I want to register my structure on dbus with
    Qt Code:
    1. qDBusRegisterMetaType<MyStruct>
    To copy to clipboard, switch view to plain text mode 
    , I'm getting an error:

    Qt Code:
    1. qmetatype.h:189: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<s_MyStruct>'
    To copy to clipboard, switch view to plain text mode 

    What's wrong ?

    Please, help me! Where is all of this well documented ?

    Thanks for all
    Last edited by JuBe; 26th March 2009 at 15:57.

Similar Threads

  1. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  2. QDevelop and CTags -> Not working
    By philwinder in forum Qt-based Software
    Replies: 13
    Last Post: 9th May 2008, 21:40
  3. Don't want QTextBrowser to look in working directory
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2007, 23:14
  4. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  5. Signals/Slots stopped working
    By Jimmy2775 in forum Qt Programming
    Replies: 8
    Last Post: 31st March 2006, 21:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.