Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Mobility / Service Framework / complex parameters, structures
Forum Update on Monday, May 27th 2025

Qt Mobility / Service Framework / complex parameters, structures

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    billouparis
    wrote on 17 Jul 2012, 07:54 last edited by
    #1

    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

    1 Reply Last reply
    0

    1/1

    17 Jul 2012, 07:54

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved