I'm still working on subclassing an external library, and have decided to use preprocessor directives to set my .h file up so the library will work with or without Qt.

For compiling my library without Qt I define a compiler flag -DNOQT.

In my .h file I put

Qt Code:
  1. #ifndef NOQT
  2. class Server: public QObject{
  3. Q_OBJECT
  4. #else
  5. class Server{
  6. #endif
To copy to clipboard, switch view to plain text mode 

I can compile this just fine without Qt. But with Qt I get the following errror:
Error: syntax error

When I try the following it works. But of course then I can't compile the library without Qt:
Qt Code:
  1. #ifndef NOQT
  2. class Server: public QObject{
  3. Q_OBJECT
  4. //#else
  5. //class Server{
  6. #endif
To copy to clipboard, switch view to plain text mode 

Any ideas on fixing this? It would be really great if I could maintain just one .h file.