Friday, April 6, 2012

Getting a Qt app working with boost using cmake

The problem:

You're using cmake to compile a Qt app which also uses boost, and you get an compilation error message like this:

error: expected ‘:’ before ‘slots’

What might be going on:

Your CMakeLists.txt file might have something like this in it:

ADD_DEFINITIONS(-DQT_NO_KEYWORDS)

The previous line is there to allow your Qt app to cooperate with boost signals and slots.  However, if you need to use Qt signals and slots, there is a workaround.

What you should do:

For Qt, use the following keywords instead:

Q_EMIT
Q_SIGNALS
Q_SLOTS

Easy enough!

Thanks, http://stackoverflow.com/questions/6399005/qt-xapian-library

No comments: