From 095c4c4121319c6bb96fea17aa44aec4669d4f4b Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 15 Jan 2012 11:17:19 +0100 Subject: [PATCH] some docu on lambda --- src/misc/lambda.cpp | 12 ++---------- src/misc/lambda.h | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/misc/lambda.cpp b/src/misc/lambda.cpp index 2d26b9e..eb29a60 100644 --- a/src/misc/lambda.cpp +++ b/src/misc/lambda.cpp @@ -1,10 +1,10 @@ // // C++ Implementation: lambda object // -// Description: +// Description: allows to use lambda expressions (C++ 11) with Qt4 // // -// Author: Konrad Rosenbaum , (C) 2008-2011 +// Author: Konrad Rosenbaum , (C) 2012 // // Copyright: See README/COPYING.GPL files that come with this distribution // @@ -12,19 +12,11 @@ #include "lambda.h" -#include -#include - MLambda::MLambda(std::function< void() > l, QObject* parent): QObject(parent) { m_ptr=l; } -MLambda::MLambda(QObject* parent): QObject(parent) -{ - m_ptr=0; -} - void MLambda::call() { if(m_ptr) diff --git a/src/misc/lambda.h b/src/misc/lambda.h index e396125..912f1fa 100644 --- a/src/misc/lambda.h +++ b/src/misc/lambda.h @@ -4,7 +4,7 @@ // Description: miscellaneous helper functions // // -// Author: Konrad Rosenbaum , (C) 2008-2011 +// Author: Konrad Rosenbaum , (C) 2012 // // Copyright: See README/COPYING.GPL files that come with this distribution // @@ -16,15 +16,24 @@ #include #include -class QWidget; +///wrapper for simple lambda expression, so it can be used with signals class MLambda:public QObject { Q_OBJECT public: + ///instantiates the lambda object, e.g. + /// \code + ///int x=55; + ///QPushButton button("Push me!"); + ///MLambda lambda([&x](){qDebug()<<"x is"<l,QObject* parent = 0); - MLambda(QObject* parent = 0); public slots: + ///generic slot that transparently executes the lambda expression void call(); private: std::functionm_ptr; -- 1.7.2.5