//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();
}
Qt 1. 按键QPushButton和文本框QTextEdit
最新推荐文章于 2023-10-14 00:00:00 发布