我的程序运行正常,但我想向其中添加一个额外的信号以显示更新的值。这是信号实际上是第一次来自类本身,因此我决定使用,this
如您所见。
和往常一样,在头文件中声明信号:
signals:
void NotifyStatusUpdated(const QString& value);
private:
SetupTab& m_setupTab;
Instrument& m_instrument;
在.cpp文件中,最后构造的是信号:
WireMessages();
emit NotifyStatusUpdated(tr("Long wait time (Ms) updated : %1 ").arg(long_wait));
然后在下面我有这个:
void SetupViewManager::WireMessages()
{
connect(&m_instrument, &Instrument::NotifyErrorDetected,
&m_setupTab, &SetupTab::onStatusUpdated); //this works
connect(&m_instrument, &Instrument::NotifyStatusUpdated,
&m_setupTab, &SetupTab::onStatusUpdated); //this works
connect(this, &Instrument::NotifyStatusUpdated, //this does not work (it doesn't build)!
&m_setupTab, &SetupTab::onStatusUpdated);
}
因此,在类参考中m_instrument
,我有另一个具有相同名称的信号。因此,在这里我想从this
类中调用信号。
error: no matching member function for call to 'connect'
connect(this, &Instrument::NotifyStatusUpdated,
^~~~~~~
这对我来说似乎不合适吗?我犯了什么愚蠢的错误?
该this
指针是SetupViewManager
在你的代码类:
connect(this, &SetupViewManager::NotifyStatusUpdated, ...
// ^^^^^^^^^^^^^^^^
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句