QT 信号和槽函数签名
在本文档中解释了信号必须具有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的插槽可以返回一个值。
但是,如果插槽连接到信号并在信号发出时调用,则返回值将被忽略。
但槽是一个普通的成员函数,可以像任何其他函数一样被调用。在这种情况下,返回值可以被调用者使用。
您链接到的文档中提到了这一点:
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 :