Qt for Qt:如何连接到具有新信号/插槽风格的信号? [英] Qwt for Qt: How to connect to signal with new signal/slot flavour?

查看:53
本文介绍了Qt for Qt:如何连接到具有新信号/插槽风格的信号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想连接到已选中的图例标签 SIGNAL.使用 Qts 旧的 Signal/Slot-Syntax 一切都很完美,但我想使用新的连接来启用编译时检查?关于如何通过新的 Signal/Slot-Syntax 连接它的任何想法?

I want to to connect to legend-label SIGNAL checked. With Qts old Signal/Slot-Syntax all is perfect, but i want to use the new connection to enable compile-time check? Any idea on how to connect it via new Signal/Slot-Syntax?

这是我的代码:

connect( m_plotLegend, SIGNAL( checked( const QVariant &, bool, int ) ), SLOT(legendChecked( const QVariant &, bool ) ) );
//connect(m_plotLegend, &QwtLegend::checked, this, &MeasurePlot::legendChecked);

使用旧语法一切都很好,使用新语法永远不会到达插槽.有任何想法吗?非常感谢!

With oldy syntax all is fine, with the new syntax the slot is never reached. Any ideas? Thank you very much!

推荐答案

您的连接应该可以正常工作.

Your connect should work.

我用您的示例代码对此进行了测试,效果很好:

I test this with your Examplecode and it works fine:

定义:

...
private slots:
void test(const QVariant &, bool);

signals:
void checked( const QVariant &, bool, int );
...

连接:

...
connect(this, &TestClass::checked, this,  &TestClass::test);

emit checked(QVariant(QString("test")), true, 1);
...

插槽:

void TestClass::test(const QVariant &, bool)
{
...
}

希望对您有所帮助.

这篇关于Qt for Qt:如何连接到具有新信号/插槽风格的信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆