Qt Mobility / Service Framework / complex parameters, structures



  • Hello all,

    I simply want to declare a service with a parameter of complex type (like a structure for example). I am working with remote services, to perform basic IPC.

    When the service is called, it sends a signal in return with a parameter to the client. If this parameter is a simple type parameter like int for instance, the signal is correctly received by the client (the client is making a connection with the service signal).
    If I introduce a struct parameter instead of the int parameter, then the client is never receiving the signal.

    Do somebody know what I have to do so that my struct is correctly sent through the Qt Mobility Service Framework?

    I even tried to declare my structure as a metatype to see if this helps, but it led to a segmentation fault!
    The following code illustrate the segmentation fault case:
    @struture.h
    #include <QObject>
    #include <QtCore/QMetaType>

    struct t_monstruct {
    t_monstruct() : a(0), b(0) {}
    t_monstruct (const t_monstruct &other)
    :
    a(other.a), b(other.b)
    {
    }

    int a;
    int b;
    

    } ;

    Q_DECLARE_METATYPE(t_monstruct)

    In the server.h:
    #include "structure.h"
    class CServer
    ...
    void sgnInitialize(t_monstruct id)
    ...
    in the server.cpp
    CServer::CServer()
    {
    qRegisterMetaType<t_monstruct>("t_monstruct");
    }
    in the service slot method ()
    {

        t_monstruct id;
        id.a = 10;
        id.b = 50;
        //returns a signal when the slot is called
        emit sgnInitialize(id);
     }
    

    In the client.cpp
    CClient::CClient()
    {
    qRegisterMetaType<t_monstruct>("t_monstruct");
    QObject::connect(service,SIGNAL(sgnInitialize(t_monstruct)),
    this,SLOT(sgnInitializelocal(t_monstruct)));
    }

         CClient::sgnInitializelocal(t_monstruct id)
        {
             qDebug()<<id.a<<" "<<is.b;
        }
    

    @

    Thank you,
    Bill


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.