QT 信号和槽函数签名

发布于 2024-10-06 18:47:36 字数 154 浏览 0 评论 0原文

在本文档中解释了信号必须具有 void 作为返回值,但是什么关于插槽?由于信号不得返回任何内容,我可以假设插槽也一样吗?

In this document is explained that signals must have void as a return value, but what about slots? Since signals must not return anything, can I assume it is the same for slots as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

贱人配狗天长地久 2024-10-13 18:47:36

您的插槽可以返回一个值。

但是,如果插槽连接到信号并在信号发出时调用,则返回值将被忽略。

但槽是一个普通的成员函数,可以像任何其他函数一样被调用。在这种情况下,返回值可以被调用者使用。

您链接到的文档中提到了这一点:

由于槽是普通的成员函数,因此直接调用时它们遵循普通的 C++ 规则。

Your slots can return a value.

However, if the slot is connected to a signal and called when the signal is emitted, the return value will be ignored.

But the slot is a normal member function and can be called like any other function. In this case, the return value can be used by the caller.

This is said in the document you link to :

Since slots are normal member functions, they follow the normal C++ rules when called directly.

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