반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 엑스퍼트생일축하해
- QTcpServer
- C++ API
- lua install
- Lua
- file read
- 중소규모택지
- lua setup
- 등록임대주택
- #신혼부부 #결혼준비 #신혼부부희망타운신혼부부특별공급
- 찾다죽는줄
- file write
- 국토교통부
- FILE TRANSFER
- 티몬삼겹살데이
- QT TCP
- 청량리역한양수자인192
- #부동산전자거래 #부동산전자계약 #부동산계약 #부동산전자계약방법 #부동산전자계약하는법 #부동산계약방법 #부동산중개수수료 #부동산중개수수료아끼기 #부동산복비아끼기
- C API
- 프리미어 영상변환
- TCP/IP
- 엑스퍼트2주년
- 월세
- lua for windows
- meta table
- 수도권주택공급
- 프리미어 영상저장
- object
- lua interpreter
- file open
Archives
- Today
- Total
Value Creator의 IT(프로그래밍 / 전자제품)
#3 QT Creator 예제 프로그램 본문
반응형
1. qlineEdit
/************** dialog.h****************/
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QDebug>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::Dialog *ui;
QString name;
int kor;
int eng;
int math;
int total;
int avg;
};
#endif // DIALOG_H
/************** dialog.cpp****************/
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
name = ui->lineEdit->text();
kor = ui->lineEdit_2->text().toInt();
eng = ui->lineEdit_3->text().toInt();
math = ui->lineEdit_4->text().toInt();
total = kor+eng+math;
avg = total / 3;
qDebug() << "이름 국어 영어 수학 총점 평균";
qDebug() << name << " " << kor << " " << eng << " " << math << " " << total << " " << avg;
}
void Dialog::on_pushButton_2_clicked()
{
this->close();
}
2. Check Box 예제
/********************* dialog.h**************/
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::Dialog *ui;
int sum;
};
#endif // DIALOG_H
/********************* dialog.cpp**************/
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
sum = 0;
if(ui->checkBox->isChecked())
sum += 650000;
if(ui->checkBox_2->isChecked())
sum += 550000;
if(ui->checkBox_3->isChecked())
sum += 150000;
if(ui->checkBox_4->isChecked())
sum += 250000;
ui->lineEdit->setText(QString::number(sum));
}
void Dialog::on_pushButton_2_clicked()
{
ui->checkBox->setChecked(false);
ui->checkBox_2->setChecked(false);
ui->checkBox_3->setChecked(false);
ui->checkBox_4->setChecked(false);
ui->lineEdit->setText("");
}
3. Radio button 예제
#ifndef DIALOG_H |
#define DIALOG_H |
#include <QDialog> |
namespace Ui { |
class Dialog; |
} |
class Dialog : public QDialog |
{ |
Q_OBJECT |
public: |
explicit Dialog(QWidget *parent = 0); |
~Dialog(); |
private slots: |
void on_pushButton_clicked(); |
void on_pushButton_2_clicked(); |
private: |
Ui::Dialog *ui; |
QString age; |
QString singer; |
}; |
#endif // DIALOG_H |
#include "dialog.h" |
#include "ui_dialog.h" |
Dialog::Dialog(QWidget *parent) : |
QDialog(parent), |
ui(new Ui::Dialog) |
{ |
ui->setupUi(this); |
} |
Dialog::~Dialog() |
{ |
delete ui; |
} |
void Dialog::on_pushButton_clicked() |
{ |
singer = ""; |
if(ui->radioButton->isChecked()) |
age = "10대"; |
if(ui->radioButton_2->isChecked()) |
age = "20대"; |
if(ui->radioButton_3->isChecked()) |
age = "30대"; |
if(ui->radioButton_4->isChecked()) |
age = "40대"; |
if(ui->radioButton_5->isChecked()) |
age = "외계인"; |
if(ui->checkBox->isChecked()) |
singer += "소녀 "; |
if(ui->checkBox_2->isChecked()) |
singer += "2엔1 "; |
if(ui->checkBox_3->isChecked()) |
singer += "선히 "; |
if(ui->checkBox_4->isChecked()) |
singer += "스데 "; |
if(ui->checkBox_5->isChecked()) |
singer += "엑조 "; |
ui->lineEdit->setText(age + "인 당신은 " + singer + "를 좋아하네요."); |
} |
void Dialog::on_pushButton_2_clicked() |
{ |
ui->radioButton->setChecked(false); |
ui->radioButton_2->setChecked(false); |
ui->radioButton_3->setChecked(false); |
ui->radioButton_4->setChecked(false); |
ui->radioButton_5->setChecked(false); |
ui->checkBox->setChecked(false); |
ui->checkBox_2->setChecked(false); |
ui->checkBox_3->setChecked(false); |
ui->checkBox_4->setChecked(false); |
ui->checkBox_5->setChecked(false); |
ui->lineEdit->setText(""); |
} |
4. Group Box 예제
#ifndef DIALOG_H |
#define DIALOG_H |
#include <QDialog> |
namespace Ui { |
class Dialog; |
} |
class Dialog : public QDialog |
{ |
Q_OBJECT |
public: |
explicit Dialog(QWidget *parent = 0); |
~Dialog(); |
private slots: |
void on_pushButton_clicked(); |
private: |
Ui::Dialog *ui; |
QString com; |
QString phr; |
}; |
#endif // DIALOG_H |
#include "dialog.h" |
#include "ui_dialog.h" |
Dialog::Dialog(QWidget *parent) : |
QDialog(parent), |
ui(new Ui::Dialog) |
{ |
ui->setupUi(this); |
} |
Dialog::~Dialog() |
{ |
delete ui; |
} |
void Dialog::on_pushButton_clicked() |
{ |
phr = ""; |
if(ui->radioButton->isChecked()) |
com = ui->radioButton->text(); |
if(ui->radioButton_2->isChecked()) |
com = ui->radioButton_2->text(); |
if(ui->radioButton_3->isChecked()) |
com = ui->radioButton_3->text(); |
if(ui->radioButton_4->isChecked()) |
com = ui->radioButton_4->text(); |
if(ui->checkBox->isChecked()) |
phr += ui->checkBox->text(); |
if(ui->checkBox_2->isChecked()) |
phr += ui->checkBox_2->text(); |
if(ui->checkBox_3->isChecked()) |
phr += ui->checkBox_3->text(); |
if(ui->checkBox_4->isChecked()) |
phr += ui->checkBox_4->text(); |
ui->lineEdit->setText("당신은 "+ com +"컴퓨터와 " + phr + "주변장치를 보유중입니다."); |
} |
반응형
'1. 프로그래밍 > 3) QT' 카테고리의 다른 글
#8 [QT4] Network programming - Client (0) | 2019.06.14 |
---|---|
#5 QT Creator 예제 - 계산기, 캘린더, 메모장 (0) | 2019.04.10 |
#4 QT Programming 예제(QListWidget, QComboBox, QTimer, QFileDialog, QGraphicsView, QTabWidget, QProgressBar) (0) | 2019.04.10 |
#2 QT Creator 예제 및 유용한 사이트 모음 (0) | 2019.04.08 |
#1 QT 5.6.3 + QT Creator 4.2.1 Ubuntu 14.04에 설치 (0) | 2019.04.08 |
Comments