Qt 4 中除了信号槽机制之外还需要 Q_OBJECT 宏的功能
我在 Windows XP 中使用 Qt 4.5。我知道我们必须使用Q_OBJECT
宏来实现信号-槽连接机制。但除此之外,还有其他原因需要使用 Q_OBJECT 宏吗?我最近了解到,对于其他一些元对象功能,我们需要 Q_OBJECT
声明。除了信号槽之外还有哪些功能?我尝试查找有关此内容的文档,但找不到任何有用的内容。欢迎任何与此相关的指示。
I am using Qt 4.5 in windows XP. I know we have to use Q_OBJECT
macro for signal - slot connection mechanism. But besides that, is there are any other reasons to use the Q_OBJECT
macro? I recently come to know that for some other meta-object features we require the Q_OBJECT
declaration. What are those features beside the Signal-slots? I tried for documentation regarding that but couldn't find anything helpful. Any pointers regarding this are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在这里找到有关何时需要 Q_OBJECT 宏的所有信息:
http:// doc.qt.digia.com/4.6/metaobjects.html
在简历中,您需要它来处理信号和槽、使用 tr 进行翻译、从 QObject 实时检索类名、了解它是否继承自其他类(自省)来设置属性并能够调用 newInstance。
希望有帮助。
You can find all you need to know about when Q_OBJECT macro is needed here:
http://doc.qt.digia.com/4.6/metaobjects.html
In resume you need it for signals and slots, to use tr for translation, to retrieve class name in real time from a QObject, to know if it inherits from other class (instrospection) to set properties and to be able to call newInstance.
Hope it helps.
据我所知,它用于检索元信息(信号槽的名称,变量)
并为对象的所有权跟踪提供支持。
(又名。只需执行 new 操作并将父级传递给这些对象,随着父级的时间流逝,它们将被确定性地处理。)
AFAIK its of use for retreiving meta information (Names of signal slots, vars)
and provides support for the ownership tracking of objects.
(aka. just do new and pass parents to these objects and they will be disposed deterministically as time of the parent passes by.)