socket.io-client-cpp icon indicating copy to clipboard operation
socket.io-client-cpp copied to clipboard

Update the Qt Demo README to Include Keyword Fix

Open kbarresi opened this issue 10 years ago • 0 comments

In the Qt demo, the project file uses the no_keywords flag, which disables the signals, slots, and emit keywords. When integrating socket.io-client-cpp into an established project, this makes things pretty difficult, since you have to go back and change all your Qt keywords to the corresponding macros (Q_EMIT, Q_SIGNAL, etc).

One way around this is to undef/def the macros around the #include for socket.io-client-cpp headers, like this:

#undef slot
#undef slots
#undef signal
#undef signals
#undef emit
#include <sio_client.h>
#define slot Q_SLOT
#define slots Q_SLOTS
#define signal Q_SIGNAL
#define signals Q_SIGNALS
#define emit Q_EMIT

You could probably wrap this up in a macro to make it easier.

I figured this would be a nice addition to the Qt Demo README, since it would mean you don't have to include the no_keywords flag in your project.

kbarresi avatar Aug 24 '15 14:08 kbarresi