按钮点击事件
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->i=0;
//绑定按钮1
connect(ui->pushButton, SIGNAL( clicked() ) , this , SLOT( btnClickedSlotFun() ) );
//绑定按钮2
connect(ui->pushButton_2, SIGNAL( clicked() ) , this , SLOT( btnClickedSlotFun() ) );
}
Widget::~Widget()
{
delete ui;
}
//处理按钮点击事件
void Widget::btnClickedSlotFun(void)
{
this->i++;
QString str = QString("你点击了%1次。").arg(this->i);
ui->label->setText(str);
}