[Qt-interest] the Data transfered by D-Bus in Qt error?

ying.cheng ying.cheng at sseec.com.cn
Fri Sep 17 01:49:54 CEST 2010


Thanks very much for your reply!

sure,Please refer to the following content:

1. These are in .h file.
typedef struct tagDeviceWriteCom
{
   quint8 iChannel;
   quint8 iStationID; 
    quint8 iType;  
   quint16 iCount;      
    quint16 iBit;        
    quint32 iDeviceName;
   quint32 iDeviceNumber; 
    quint32 iValue;      

    static void registerMetaType();

}DEVICE_IFO_COM ;

 QDBusArgument &operator<<(QDBusArgument &argument, const DEVICE_IFO_COM  &dev);

 const QDBusArgument &operator>>(const QDBusArgument &argument, DEVICE_IFO_COM  &dev);

Q_DECLARE_METATYPE(DEVICE_IFO_COM )



2.These are in .cpp file.

void DEVICE_IFO_COM ::registerMetaType()
{
    qRegisterMetaType<DEVICE_IFO_COM >("DEVICE_IFO_COM ");
    qDBusRegisterMetaType<DEVICE_IFO_COM >();
}
 
QDBusArgument &operator<<(QDBusArgument &argument, const DEVICE_IFO_COM & dev)
{
    argument.beginStructure();
    argument << dev.iChannel << dev.iStationID << dev.iType << dev.iCount << dev.iBit<< dev.iDeviceName << dev.iDeviceNumber << dev.iValue;
    argument.endStructure();
    return argument;
}

 

const QDBusArgument &operator>>(const QDBusArgument &argument, DEVICE_IFO_COM  &dev)
{
    argument.beginStructure();
    argument >> dev.iChannel >> dev.iStationID >> dev.iType >> dev.iCount >> dev.iBit >>  dev.iDeviceName >> dev.iDeviceNumber >> dev.iValue;
    argument.endStructure();
    return argument;
}

3.Process A and Process B use the same .h and .cpp file about the Structure.

4.Then I call "DEVICE_IFO_COM ::registerMetaType();" in main.cpp.






-----------------
Best Regards & Sincere Appreciation




More information about the Qt-interest-old mailing list