Results 1 to 13 of 13

Thread: Retriving structure in qt-urgent.please reply.

  1. #1
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Retriving structure in qt-urgent.please reply.

    i am sending a strucutre though dbsu-glib as follow.
    typedef struct{
    int a;
    int b;
    char [5];
    }payload;

    payload p={5,5,"ARRAY"};

    And i am able to send this structure data with function call,which i can see in dbus-monitor as follow.
    array[
    array[
    byte 5;
    byte 5;
    byte 65;
    ....
    byte 89;
    ]
    ]
    signature is :'aay'
    up to this every thing is OK.

    But on qt side(receiver) i dont have any idea as to how to receive this message.what can be the argument of my function in qt application?

    i tried with QByteArray,QStringList but no succusses.now,what to do?

    These are my confusion:
    (1)how to imeplement a method in qt ,which can suites to 'aay' signatures displayed in dbus-monitor?
    (2) if we use QDBusArgument for receving structure and arrays,than how should be an implementatin.If remote application is sending the structure,than how to retrieve it at qt ?
    (3)what are the ways of receiving structures in qt?

    dear freind,no body is replying since long.is it so no one knows about this??

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retriving structure in qt-urgent.please reply.

    Most likely the arguments are (int, int, QByteArray). I suggest you use qdbusviewer to find your method and see what the argument types are. Furthermore there is an example in QDBusArgument docs that shows how to deal with structures.

    dear freind,no body is replying since long.is it so no one knows about this??
    We don't like it when someone uses the word "urgent" in the thread title. It tends to cause significant delays receiving answers to questions. Ignoring proper formatting and language in your posts also doesn't help with getting replied.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Retriving structure in qt

    Dear Wysota,

    Thank you very much for replying. I am really sorry for my mistakes. Please, forgive me about my unformated post because of poor english.

    I have tried with qdbusviewer also many times. But it will only accept this arguments only.

    In my case, i am only getting the refrence to a structure(i dont know what is inside it,so i have to try to send it as a string of bytes or array of bytes),i am making GPtrArray (used for adding any mixed type of data) and sending by dbus_g_proxy_begin_call to a remote function.

    but,when i send this its showing 'aay' signature. now,if one member element gets added or removed of any data type by the 3 rd application(which is giving me a structure).Than what to do. Probably the best way is to send as byte stream with message identifier. And interpret it as receiver side as per the message id received.

    But,still i am not able to receive with the (int, int, QByteArray). i have used QDBusArgument ,but than confusion is that,what can be argument of method ?is it foo(mystructure)?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retriving structure in qt

    Did you find your method using qdbusviewer? Can you attach a screenshot of a window that opens after doubleclicking the method name in qdbusviewer?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Retriving structure in qt-urgent.please reply.

    yah,i have already seen all the methods of my class.And i if i give it foo(int,int,QString),than i can call with the qdbusviewer,but with the arguments as (int,int,QString) only.

    And when i call from remote glib-dbus application with the arguments as "array of array of integers" i.e. 'aay' which is shown by the dbus-monitor after passing with the GPtrArray . It shows the message "no member named "foo" with signature 'aay' ". I can call all other method which takes "array of strings","int" and all basic data types. But 'aay' is not working.

    now what should i do?. If any how i can make a string from the structure given to me,than i will have to send as string and i will be able to receive as QString .

    can i have another solution?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retriving structure in qt-urgent.please reply.

    Quote Originally Posted by savaliya_ambani View Post
    yah,i have already seen all the methods of my class.And i if i give it foo(int,int,QString),than i can call with the qdbusviewer,but with the arguments as (int,int,QString) only.
    So that's what you need to use.

    now what should i do?. If any how i can make a string from the structure given to me,than i will have to send as string and i will be able to receive as QString .

    can i have another solution?
    The method declaration claims the last argument is a 5 byte character array - meaning a string. I'm not sure how a two dimensional array of integers would fit there. If you can, you should redesign the original method, it's declared incorrectly.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Retriving structure in qt-urgent.please reply.

    i cant do this with (int,int,Qstring),because i dont know the elements of structure.I will get only refrence to a structure. This is not possible in the case i am fighting. i must have to send it as one string.

    i have found a way for sending a structure as a string by memcpy() and than sending the memory data upto the sizeof(structure) .But the problem with this is that it will get terminated if any structure variable is 0(zero).

    Any idea more on this,as to how to handle this?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retriving structure in qt-urgent.please reply.

    Redesign the structure. QString holds unicode strings and if you try to fit arbitrary data in it, it might get corrupted during the conversion to Unicode.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Retriving structure in qt-urgent.please reply.

    i didnt get this. How can i redesign,the data memebers will be there still. can u please give me example of structure ,which consists of int,string,int,chat,boolean.

    When a single null terminated string found,it will terminate it there.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retriving structure in qt-urgent.please reply.

    Quote Originally Posted by savaliya_ambani View Post
    i didnt get this. How can i redesign,the data memebers will be there still.
    Change the program that declares the DBus method to not use char[5].
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Nov 2007
    Posts
    55
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Retriving structure in qt-urgent.please reply.

    As a Windows programmer, I am not in DBUS, but what you have to do is mentioned in the part "The QtDBus Type System | Extending the type system" and "QDBusArgument Class Reference" of the documentation:
    1. declare your structure as a Qt meta-type (Q_DECLARE_METATYPE)
    2. reimplement the streaming operators << and >>
    3. in your programm, you should register (qDBusRegisterMetaType()) your datatype

    Concerning the char array issue, you could use a QString or send the chars one by one, surely not elegant but it could work...

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retriving structure in qt-urgent.please reply.

    Quote Originally Posted by alainstgt View Post
    Concerning the char array issue, you could use a QString or send the chars one by one, surely not elegant but it could work...
    As I understand it the point is those chars are not actually chars but pointers to pointers to integers (or something like that, it's hard to understand the OP). Otherwise I don't see what the problem is, as I said the docs for QDBusArgument contain a nice example of dealing with structures.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Retriving structure in qt-urgent.please reply.

    As i said its not in my hand to change the structure. I will get only refrence to it,and need to convert it into a string.



    In another method i am passing a structure from nonqt application. And its signature shown is '(suu)',means structure consisting of "string,unsiged int,unsigned int." . But,i cant register a method from qt which can accept a method call like this.Even with qdbusviewer cant do this.

    And if i do

    1. declare your structure as a Qt meta-type (Q_DECLARE_METATYPE)
    2. reimplement the streaming operators << and >>
    3. in your programm, you should register (qDBusRegisterMetaType()) your datatype

    than there will not be a method which can have the foo(string,unsiged int,unsigned int.) method.

Similar Threads

  1. howto send a reply using QDBusMessage
    By HERC in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2010, 16:32
  2. [URGENT] Weird compile error [URGENT]
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 24th May 2008, 23:54

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.