1. 修改.pro文件
添加:
CONFIG += c++11
2. 代码中就可以使用lmada了
#include "widget.h"
#include "ui_widget.h"
#include <QtDebug>
#include <QKeyEvent>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->setWindowTitle("微信");
timerID = this->startTimer(1000);
this->timerID2 = this->startTimer(500);
connect(ui->myButton,&QPushButton::pressed,
/* =是为了可以访问外面的变量,一般就这样写就好了 */
[=](){
qDebug() << "mybutton 按下";
}
);
}