fiz
fiz

Reputation: 936

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

My program was working fine but I wanted to add an extra signal into it to display an updated value. This is the first time the signal was actually coming from the class itself, so I decided to use this as you shall see.

The Program

In my header file, as usual I declare my signal:

signals:
    void NotifyStatusUpdated(const QString& value);

private:

    SetupTab& m_setupTab;
    Instrument& m_instrument;

In the .cpp, the final thing constructed is the signal:

WireMessages();
emit NotifyStatusUpdated(tr("Long wait time (Ms) updated : %1 ").arg(long_wait));

Then below I have this:

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);
}

So in my class reference m_instrument, I have another signal which has the same name. So here I want to call the signal from this class instead.

The Error

error: no matching member function for call to 'connect'
        connect(this, &Instrument::NotifyStatusUpdated,
        ^~~~~~~

This just does not seem right to me? What stupid mistake am I making?

Upvotes: 1

Views: 2354

Answers (1)

Piotr Skotnicki
Piotr Skotnicki

Reputation: 48457

The this pointer is of SetupViewManager class in your code:

connect(this, &SetupViewManager::NotifyStatusUpdated, ...
//             ^^^^^^^^^^^^^^^^

Upvotes: 3

Related Questions