error expected constructor, destructor, or type conversion before ‘ when trying to register a structure from my C library
Solved
General and Desktop
-
Hello, i'm trying to register a structure in my C library, in order to use it with signals and slots.
#ifndef MQTTMANAGER_H #define MQTTMANAGER_H #include <QObject> #include <QMetaType> #include "core/interface/MQTTClient.h" class MqttManager: public QObject { Q_OBJECT public: MqttManager(QObject *parent = 0); void setupParameters(); titanium_DbErrorCode doMqttClientCreate(); titanium_DbErrorCode doConnect(); titanium_DbErrorCode doPublish(QString& p_topic,const QString& p_payload, int p_qos=0,int p_retain=false); titanium_DbErrorCode doSubscribe(QString p_topic,int p_qos=0); void doUnsubscribe(QString& p_topic); void doDisconnect(); void doMqttClientDestroy(); static void message_Cb(void* p_ReceiverStruct, void* p_Data); void signalEmit(QString); static MqttManager* m_manager; public slots: signals: void messageReceived(QString); private: QString m_hostname; int m_port; titanium_MQTTClient *m_client; titanium_MQTTConnectionSettings m_connectionSettingsMQTT; titanium_MQTTOnMessageCallback m_messageCallBack; bool m_autoReconnect; }; Q_DECALARE_METATYPE(titanium_MQTTMessage);
In my main function i use QRegisterMetatype because i have communication between threads:
```qRegisterMetaType<titanium_MQTTMessage>();
I get the error: expected constructor, destructor, or type conversion before ‘;’ token Q_DECALARE_METATYPE(titanium_MQTTMessage); ^