QT 槽和信号参数
我是 Qt 新手,偶然发现了一个在 Google 上找不到答案的问题。
假设我想发送加速度和速度场。我定义了一个自定义信号:
setProperties(QString,double,double,bool)
但是,如何在这样的语句中区分速度和加速度之间的区别?
connect(dialog, SIGNAL(setProperties(QString,double,double,bool)),
this, SLOT(somerandomslot()));
randomslot 需要获取速度场和加速度场并对其进行操作,但在上面的 SIGNAL 中它们只是 double 。
I am new to Qt and stumbled across a problem that I could not find an answer for on Google.
Say I want to send an acceleration and velocity field. I define a custom signal :
setProperties(QString,double,double,bool)
However, how do I tell the difference between velocity and acceleration in such a statement?
connect(dialog, SIGNAL(setProperties(QString,double,double,bool)),
this, SLOT(somerandomslot()));
randomslot
needs to get the velocity field and acceleration fields and manipulate them, but in the above SIGNAL
they are just double
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,您的
somerandomslot()
函数可能应该有一个匹配的函数签名,以便信号中的emit
值可以传递给它:然后您的 connect 调用将看起来像这样:
当您的
somerandomslot()
被调用时,您将可以访问这些变量。In this case your
somerandomslot()
function should probably have a matching function signature so that the valuesemit
ed in your signal can get passed to it:then your connect call would look like this:
and when your
somerandomslot()
gets called you'll have access to those variables.