我想在使用connect
函数时使用Qt中的lambda表达式。
我的代码是这样的:在lambda表达式中使用Void表达式错误无效
for(int i = propertyToNodeMap.size() -1 ; i >= 0 ; --i)
{
connect(&mainDialog,mainDialog.accepted(),[=](){
; //sth ....
});
}
我使用Qt 5.3和MinGW为编译器在Windows 7
的错误信息是:
error: invalid use of void expression
});
^
而且我用Qt文档和here作为参考来实现这段代码。 问候,
在C++中没有'foreach'。 – 2014-09-11 07:46:39
@AntonSavin Qt创建者有这个选项,你可以使用它作为容器,它是框架特性之一。看看http://qt-project.org/forums/viewthread/15487 – bahrami307 2014-09-11 07:48:52
@AntonSavin http://qt-project.org/doc/qt-4.8/containers.html – bahrami307 2014-09-11 07:57:24