#include "form.h"
#include "ui_form.h"
#include <QString>
#include <QLabel>
Form::Form(QWidget *parent) :
QWidget(parent),
ui(new Ui::Form)
{
counter = 0;
ui->setupUi(this);
}
Form::~Form()
{
delete ui;
}
void Form::on_pushButton_clicked()
{
counter++;
ui->label->setText(QString::number(counter));
}
Initialize your member in the constructor not in the header. And put the definition of your counter member to the private section not to the private slot section.