![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Snippets de código C++11 para Qt5Monday, 17 October 2016, 9:53:26 am Uso de lambdas con signals/slots Es este post
#include <QCoreApplication>
#include <QDebug>
#include <QObject>
#include <QTimer>
void freeFunction() {
qDebug() << "free function";
}
static void staticFunction() {
qDebug() << "static function";
}
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
QTimer timer;
timer.setInterval(500);
QObject::connect(&timer, &QTimer::timeout, staticFunction);
QObject::connect(&timer, &QTimer::timeout, freeFunction);
QObject::connect(&timer, &QTimer::timeout, []() { qDebug() << "lambda"; });
timer.start();
return app.exec();
}
|