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

Stephen Chu stephen at ju-ju.com
Thu Nov 1 19:49:27 CET 2012


On 11/1/12 1:17 PM, Thiago Macieira wrote:
> On quinta-feira, 1 de novembro de 2012 13.03.56, Stephen Chu wrote:
>> I find out what QPrivateSignal is for but it's not clear if lambda can
>> still be used to connect to such private signals.
>>
>> If I connect QTimer::timeout() to a slot that takes no argument, it
>> compiles fine. But when I try to connect to a lambda function without
>> any argument, the results in the mentioned error.
>
> Can you rephrase and/or give us code samples?
>
> "takes no arguments" and "without any argument" are semantically the same in
> English.

This doesn't work (compile error):

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

This does:
	
	QTimer timer;
	auto label = new QLabel;
	QObject::connect(&timer, &QTimer::timeout, label, &QWidget::show);


Again. This is using clang 3.1 with QMAKE_CXXFLAGS += -std=c++11




More information about the Development mailing list