Qt 4 中除了信号槽机制之外还需要 Q_OBJECT 宏的功能

发布于 2024-09-05 12:38:20 字数 222 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冬天旳寂寞 2024-09-12 12:38:20

您可以在这里找到有关何时需要 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.

因为看清所以看轻 2024-09-12 12:38:20

据我所知,它用于检索元信息(信号槽的名称,变量)
并为对象的所有权跟踪提供支持。
(又名。只需执行 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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文