simgineer
simgineer

Reputation: 1898

Processing of Q_OBJECT in legacy non qmake build?

I have a legacy build that doesn't use qmake but I'd like to add QUdpSocket and connect it with a signal and a slot. I have a single class that uses Q_OBJECT. What do I need to do to properly process the Q_OBJECT directive if I want signals and slots to be available but I am not using qmake.

Can I just substitute the original myclass.h file with the output of the "$moc myclass.h"? Or is the output in addition to the original file?

Is this the likely new make directives?

m_myclass.h : myclass.h
    moc myclass.h > m_myclass.h

Upvotes: 0

Views: 53

Answers (1)

Matteo Italia
Matteo Italia

Reputation: 126867

The MOC actually generates .cpp files to be compiled along with the rest of the project; so, that would be more something like:

moc_myclass.cpp: myclass.h
    moc myclass.h > moc_myclass.cpp

moc_myclass.o: moc_myclass.cpp
    g++ ${CFLAGS} moc_myclass.cpp -o moc_myclass.o // whatever

and then add moc_myclass.o to the linking step of your final executable.

Upvotes: 1

Related Questions