我刚开始使用 Qt 并注意到所有示例类定义都将宏 Q_OBJECT 作为第一行.这个预处理器宏的目的是什么?
I just started using Qt and noticed that all the example class definitions have the macro Q_OBJECT as the first line. What is the purpose of this preprocessor macro?
来自 Qt 文档:
元对象编译器,moc,是处理 Qt 的 C++ 的程序扩展.
The Meta-Object Compiler, moc, is the program that handles Qt's C++ extensions.
moc 工具读取 C++ 头文件.如果找到一个或多个类包含 Q_OBJECT 的声明宏,它生成一个 C++ 源文件包含元对象代码那些课.除其他事项外,需要元对象代码信号槽机制运行时类型信息,以及动态属性系统.
The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes. Among other things, meta-object code is required for the signals and slots mechanism, the run-time type information, and the dynamic property system.
这篇关于Q_OBJECT 宏有什么作用?为什么所有 Qt 对象都需要这个宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 C++ 中读取和操作 CSV 文件数据?How can I read and manipulate CSV file data in C++?(如何在 C++ 中读取和操作 CSV 文件数据?)
在 C++ 中,为什么我不能像这样编写 for() 循环:In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,为什么我不能像这样编写 for() 循环: for(
OpenMP 如何处理嵌套循环?How does OpenMP handle nested loops?(OpenMP 如何处理嵌套循环?)
在循环 C++ 中重用线程Reusing thread in loop c++(在循环 C++ 中重用线程)
需要精确的线程睡眠.最大 1ms 误差Precise thread sleep needed. Max 1ms error(需要精确的线程睡眠.最大 1ms 误差)
是否需要“do {...} while ()"?环形?Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?环形?)