在Qt DBUS中编组16位unsigned int

时间:2012-05-11 16:57:54

标签: qt types marshalling dbus

在QT中,我们有以下16位无符号可用表示:

typedef unsigned short int  uint16_t;   (in stdint.h)
typedef unsigned short      quint16;    (in qglobal.h)

这两者有什么区别?我有一个外部头文件(我不能修改),后面有一个typedef:

typedef uint16_t MyCustomId;

此“MyCustomId”字段用于插槽信号以与DBUS通信。

class CMyDbusProxy: public QDBusAbstractInterface
{
Q_OBJECT
Q_SIGNALS: 
    void Test(MyCustomId);
};

问题是在CMyDbusProxy中没有注意到从DBUS服务发送的信号,因此根本不会触发任何插槽。如果我手动将typedef更改为(我不应该这样做,它仅用于测试):

typedef quint16 MyCustomId;
一切正常。 DBUS服务端的信号有“signature ='q'”,表示uint16。

如何克服此类型匹配问题并使用“uint16_t”接收信号?

0 个答案:

没有答案