没有匹配的成员函数来调用"连接" - 使用"this"时

No Matching Member Function to Call 'connect' - When Using 'this'

本文关键字:连接 使用 this 调用 函数 成员      更新时间:2023-10-16

我的程序运行良好,但我想在其中添加一个额外的信号来显示更新的值。这是第一次信号实际上来自类本身,所以我决定使用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, ...
//             ^^^^^^^^^^^^^^^^