[英]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. 我有一个不使用qmake的旧版本,但我想添加QUdpSocket并将其与信号和插槽连接。 I have a single class that uses Q_OBJECT. 我有一个使用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. 如果我希望信号和插槽可用,但我没有使用qmake,该怎么做才能正确处理Q_OBJECT指令。
Can I just substitute the original myclass.h file with the output of the "$moc myclass.h"? 我可以用“ $ moc myclass.h”的输出替换原始的myclass.h文件吗? Or is the output in addition to the original file? 还是输出除了原始文件之外?
Is this the likely new make directives? 这可能是新的make指令吗?
m_myclass.h : myclass.h
moc myclass.h > m_myclass.h
The MOC actually generates .cpp files to be compiled along with the rest of the project; MOC实际上会生成.cpp文件,以与项目的其余部分一起进行编译。 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. 然后将moc_myclass.o
添加到最终可执行文件的链接步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.