일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- Lua
- 찾다죽는줄
- 프리미어 영상변환
- #신혼부부 #결혼준비 #신혼부부희망타운신혼부부특별공급
- lua install
- FILE TRANSFER
- C API
- 엑스퍼트생일축하해
- TCP/IP
- QT TCP
- C++ API
- file read
- file write
- 등록임대주택
- 중소규모택지
- 국토교통부
- lua interpreter
- 청량리역한양수자인192
- 프리미어 영상저장
- 티몬삼겹살데이
- 엑스퍼트2주년
- lua setup
- 월세
- object
- lua for windows
- #부동산전자거래 #부동산전자계약 #부동산계약 #부동산전자계약방법 #부동산전자계약하는법 #부동산계약방법 #부동산중개수수료 #부동산중개수수료아끼기 #부동산복비아끼기
- QTcpServer
- 수도권주택공급
- file open
- meta table
- Today
- Total
Value Creator의 IT(프로그래밍 / 전자제품)
#5 QT Creator 예제 - 계산기, 캘린더, 메모장 본문
1. 계산기
소스코드
<widget.h>
#ifndef WIDGET_H
#define WIDGET_H
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_pushButton_5_clicked();
void on_pushButton_6_clicked();
void on_pushButton_7_clicked();
void on_pushButton_8_clicked();
void on_pushButton_9_clicked();
void on_pushButton_10_clicked();
void on_pushButton_14_clicked();
void on_pushButton_11_clicked();
void on_pushButton_12_clicked();
void on_pushButton_16_clicked();
void on_pushButton_15_clicked();
void on_pushButton_17_clicked();
void on_pushButton_13_clicked();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
<widget.cpp>
#include "widget.h" #include "ui_widget.h"
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); }
Widget::~Widget() { delete ui; }
void Widget::on_pushButton_clicked() { if(QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text()+"1"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text()+"1"); } }
void Widget::on_pushButton_2_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "2"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "2"); } }
void Widget::on_pushButton_3_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "3"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "3"); } }
void Widget::on_pushButton_5_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "4"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "4"); } }
void Widget::on_pushButton_6_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "5"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "5"); } }
void Widget::on_pushButton_7_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "6"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "6"); } }
void Widget::on_pushButton_9_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "7"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "7"); } }
void Widget::on_pushButton_10_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "8"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "8"); } }
void Widget::on_pushButton_11_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "9"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "9"); } }
void Widget::on_pushButton_14_clicked() { if (QString::compare (ui->lineEdit_2->text(), "") == 0) { ui->lineEdit->setText(ui->lineEdit->text() + "0"); } else { ui->lineEdit_3->setText(ui->lineEdit_3->text() + "0"); } }
void Widget::on_pushButton_4_clicked() { ui->lineEdit_2->setText("+"); }
void Widget::on_pushButton_8_clicked() { ui->lineEdit_2->setText("-"); }
void Widget::on_pushButton_12_clicked() { ui->lineEdit_2->setText("*"); }
void Widget::on_pushButton_16_clicked() { ui->lineEdit_2->setText("/"); }
void Widget::on_pushButton_15_clicked() { if(ui->lineEdit_2->text() == "+") ui->lineEdit_4->setText(QString::number(ui->lineEdit->text().toInt(NULL, 10) + ui->lineEdit_3->text().toInt(NULL, 10))); else if(ui->lineEdit_2->text() == "-") ui->lineEdit_4->setText(QString::number(ui->lineEdit->text().toInt(NULL, 10) - ui->lineEdit_3->text().toInt(NULL, 10))); else if(ui->lineEdit_2->text() == "*") ui->lineEdit_4->setText(QString::number(ui->lineEdit->text().toInt(NULL, 10) * ui->lineEdit_3->text().toInt(NULL, 10))); else if(ui->lineEdit_2->text() == "/") ui->lineEdit_4->setText(QString::number(ui->lineEdit->text().toInt(NULL, 10) / ui->lineEdit_3->text().toInt(NULL, 10))); }
void Widget::on_pushButton_17_clicked() { this->close(); }
void Widget::on_pushButton_13_clicked() { ui->lineEdit->setText(""); ui->lineEdit_2->setText(""); ui->lineEdit_3->setText(""); ui->lineEdit_4->setText(""); }
2. 캘린더 데이터베이스 SQL
3. 메모장
'1. 프로그래밍 > 3) QT' 카테고리의 다른 글
#9 [QT4] Network programming - Server (0) | 2019.06.14 |
---|---|
#8 [QT4] Network programming - Client (0) | 2019.06.14 |
#4 QT Programming 예제(QListWidget, QComboBox, QTimer, QFileDialog, QGraphicsView, QTabWidget, QProgressBar) (0) | 2019.04.10 |
#3 QT Creator 예제 프로그램 (0) | 2019.04.09 |
#2 QT Creator 예제 및 유용한 사이트 모음 (0) | 2019.04.08 |