cpp
//ex2.cpp
#include "ex2.h"
#include "ui_ex2.h"
int static cnt = 0;
Ex2::Ex2(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Ex2)
{
ui->setupUi(this);
}
Ex2::~Ex2()
{
delete ui;
}
void Ex2::on_pushButtonMy1_clicked()
{
cnt ++;
QString str = QString::number(cnt,10);
ui->textEditMy1->setText(str);
}
void Ex2::on_pushButtonMy2_clicked()
{
if(cnt > 0) cnt --;
QString str = QString::number(cnt,10);
ui->textEditMy1->setText(str);
}
//main.cpp
#include "ex2.h"
#include <QtSerialPort/QtSerialPort>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Ex2 w;
w.show();
return a.exec();
}