I was able to get it to work by putting two separate class declarations inside the #ifndef #else statements. This solution is acceptable, especially since I don't have much time.

Although I gave Codepoet's idea a quick try, since this would certainly be more elegant. But the problem is that I do have an #ifndef statement inside my cpp code so that I can emit a Qt signal. If I set my classes up so that the "Qt-enabled" server class inherits from the "Qt-ignorant" class, it complains about the emit signal in the cpp code not being defined in the base class. And there is no easy way around this. So I'll go with the first approach.