Alecs
Alecs

Reputation: 2316

New Qt signals syntax error with overload without this

When I write like

 connect(m_someClasspointer, &SomeClassName::SignalA, &CurrentClass::slotMethod);

I got error

error: no matching function for call to 'QtPrivate::FunctionPointer<void (CurrentClass::*)()>::call(void (CurrentClass::*&)(), QObject*&, void**&)'
             FuncType::template call<Args, R>(static_cast<QStaticSlotObject*>(this_)->function, r, a);

while with

 connect(m_someClasspointer, &SomeClassName::Signal, this, &CurrentClass::slotMethod);

everything is ok. But there is overload in QObject

inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
                                        const char *amember, Qt::ConnectionType atype) const

So I absolutely don't understand why first variant didn't work..

Upvotes: 1

Views: 266

Answers (1)

01d55
01d55

Reputation: 1912

You are trying to pass direct function pointers, while the overload you reference takes const char *. If you look, you'll find that passing direct function pointers is supported by a template, and there isn't a non-static form of that template.

For overloads that use const char *, use the macros SIGNAL and SLOT, e.g. SIGNAL(SignalA()) and SLOT(slotMethod()).

Upvotes: 5

Related Questions