mainwindow.h Code: class MainWindow { ........ private: static int _clickCounter; }; mainwindow.cpp in the first line of the file just after all the #includes define this variable, Code: int MainWindow::_clickCounter = 0; and modfiy your slot with something like this Code: void MainWindow::on_Button_clicked() { ui->label->setText(QString("this is text %1").arg(QString::number(++_clickCounter) ); }
class MainWindow { ........ private: static int _clickCounter; };
int MainWindow::_clickCounter = 0;
void MainWindow::on_Button_clicked() { ui->label->setText(QString("this is text %1").arg(QString::number(++_clickCounter) ); }