[Interest] Qt5: Problem connecting QTimer::timeout() to lambda

Stephen Chu stephen at ju-ju.com
Thu Nov 1 16:18:29 CET 2012


I just updated from Qt5 git and the following code results in compile error:

	QTimer timer;
	connect(&timer, &QTimer::timeout, [=](){});

Error resulted from clang 3.1:

/Qt/5.0/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:395:13: 
error: no matching function for call to object of type 
'PageLogPanel::<lambda at ../../Dropbox/Client2012/PageLogPanel.cpp:47:36>'
             f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type 
*>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
             ^
/Qt/5.0/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:434:79: 
note: in instantiation of member function 
'QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, 
QtPrivate::List<QTimer::QPrivateSignal>, void, PageLogPanel::<lambda at 
../../Dropbox/Client2012/PageLogPanel.cpp:47:36> >::call' requested here
             FunctorCall<typename Indexes<N>::Value, SignalArgs, R, 
Function>::call(f, arg);
 
        ^
/Qt/5.0/qtbase/include/QtCore/../../src/corelib/kernel/qobject_impl.h:193:17: 
note: in instantiation of function template specialization 
'QtPrivate::Functor<PageLogPanel::<lambda at 
../../Dropbox/Client2012/PageLogPanel.cpp:47:36>, 
1>::call<QtPrivate::List<QTimer::QPrivateSignal>, void>' requested here
                 FuncType::template call<Args, 
R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
                 ^
/Qt/5.0/qtbase/include/QtCore/../../src/corelib/kernel/qobject_impl.h:202:71: 
note: in instantiation of member function 
'QtPrivate::QFunctorSlotObject<PageLogPanel::<lambda at 
../../Dropbox/Client2012/PageLogPanel.cpp:47:36>, 1, 
QtPrivate::List<QTimer::QPrivateSignal>, void>::impl' requested here
         explicit QFunctorSlotObject(const Func &f) : 
QSlotObjectBase(&impl), function(f) {}
                                                                       ^
/Qt/5.0/qtbase/include/QtCore/../../src/corelib/kernel/qobject.h:285:32: 
note: in instantiation of member function 
'QtPrivate::QFunctorSlotObject<PageLogPanel::<lambda at 
../../Dropbox/Client2012/PageLogPanel.cpp:47:36>, 1, 
QtPrivate::List<QTimer::QPrivateSignal>, void>::QFunctorSlotObject' 
requested here
                            new QtPrivate::QFunctorSlotObject<Func2, 
SignalType::ArgumentCount, typename SignalType::Arguments, typename 
SignalType::ReturnType>(slot),
                                ^
../../Dropbox/Client2012/PageLogPanel.cpp:47:2: note: in instantiation 
of function template specialization 'QObject::connect<void 
(QTimer::*)(), PageLogPanel::<lambda at 
../../Dropbox/Client2012/PageLogPanel.cpp:47:36> >' requested here
         connect(&timer, &QTimer::timeout, [=](){});
         ^
../../Dropbox/Client2012/PageLogPanel.cpp:47:36: note: candidate 
function not viable: requires 0 arguments, but 1 was provided
         connect(&timer, &QTimer::timeout, [=](){});
                                           ^

It seems 
http://qt.gitorious.org/qt/qtbase/commit/dee57bc91080740201a0bf0b8c42eb374ee696f3 
added QPrivateSignal to the signal signature?



More information about the Interest mailing list