no matching member function for call to 'connect'
-
Here is the full error message:
/Users/thomasvanbesien/IHM_Bobink/lineedityarnsetpoint.cpp:14: error: no matching member function for call to 'connect' ../IHM_Bobink/lineedityarnsetpoint.cpp:14:3: error: no matching member function for call to 'connect' connect(lineEdit, &QLineEdit::editingFinished, signalMapper, &QSignalMapper::map); ^~~~~~~ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:181:36: note: candidate function not viable: no known conversion from 'void (QLineEdit::*)()' to 'const char *' for 2nd argument static QMetaObject::Connection connect(const QObject *sender, const char *signal, ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:184:36: note: candidate function not viable: no known conversion from 'void (QLineEdit::*)()' to 'const QMetaMethod' for 2nd argument static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:432:41: note: candidate function not viable: no known conversion from 'void (QLineEdit::*)()' to 'const char *' for 2nd argument inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal, ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:201:43: note: candidate template ignored: couldn't infer template argument 'Func2' static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:242:13: note: candidate template ignored: couldn't infer template argument 'Func2' connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:287:13: note: candidate template ignored: couldn't infer template argument 'Func2' connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:233:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ /Users/thomasvanbesien/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qobject.h:276:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^
-
@t-vanbesien said in no matching member function for call to 'connect':
couldn't infer template argument 'Func2'
I'm not sure, but this is probably the one that relates to your situation.
In any case you need to do the "qoverload" I suggested and is in the SO post. -
Thank you for the help. I was able to make it work, I changed the erroneous line to:
connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of<>(&QSignalMapper::map));
I'm not completely sure why it works. C++ templates are still a bit fuzzy to me, but I'll post an explanation when I understand exactly what the problem was.
-
@t-vanbesien said in no matching member function for call to 'connect':
connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of<>(&QSignalMapper::map));
I don't believe that is a working copy/paste, I think you mean
QOverload<>::of(&QSignalMapper::map)
?C++ templates are still a bit fuzzy to me, but I'll post an explanation when I understand exactly what the problem was.
There are 2 possible overloads:
QSignalMapper::map()
&QSignalMapper::map(QObject *)
.
QOverload<>::of(...)
picks the first one (no parameters),QOverload<QObject *>::of(...)
picks the second one. The bit inside<...>
specifies the parameters. It's kind of like a cast. -
@JonB said in no matching member function for call to 'connect':
I don't believe that is a working copy/paste, I think you mean
QOverload<>::of(&QSignalMapper::map)
?No, the line I copy/pasted does compile and run and has the expected behavior.
-
@t-vanbesien
Interesting. Could you tell me/give me a reference to where you got an example or documentation which usesQOverload<...>::of<...>(...)
rather thanQOverload<...>::of(...)
, please? Note the bit I am asking about is the::of<>
having a<...>
segment? -
@JonB
I don't know ? I'm not sure I understand the question. I usedQOverload<...>::of<...>()
because you wrote it in your first answer to this post. I can't find any documentation about it. If you want a working example I can share the class .cpp and .h of the class and the small debug function I made to make sure it is working properly. You can put it in an empty qt project to check.
-
@t-vanbesien said in no matching member function for call to 'connect':
because you wrote it in your first answer to this post.
Damn! So I did, I was guessing at that point! :( Now I know better, from the SO link I gave you :)
I suggest that you try copy/paste the following line to replace yours:
connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of(&QSignalMapper::map));
Even though your
::of<>(
apparently works, it should be::of(
. Don't confuse yourself by using my guessed-syntax, for when you come back to it. -
I replaced the line so that now it is:
connect(lineEdit, &QLineEdit::editingFinished, signalMapper, QOverload<>::of(&QSignalMapper::map));
And everything is still working properly.
By the way, you wrote 'IOC' in one of your answers, what does it mean ?
-
@t-vanbesien said in no matching member function for call to 'connect':
By the way, you wrote 'IOC' in one of your answers, what does it mean ?
I wrote
OIC
=>O-I-C
=> "Oh I See" :)