-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
46 lines (43 loc) · 1.21 KB
/
mainwindow.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
this->close();
}
void MainWindow::on_pushButton_2_clicked()
{
QMessageBox::information(this,tr("Clicked!"),tr("The button was clicked."));
QString hello=tr("[Message] The button was clicked. function 'on_pushButton_2_clicked ()' called.\n");
std::string hello1 = hello.toUtf8().constData();//Qstringからstd::stringへ
std::cout << hello1;
}
void MainWindow::on_actionAbout_Qt_triggered()
{
QMessageBox::aboutQt(this);
}
void MainWindow::slot1(){
QMessageBox::warning(this,tr("Warning"),tr("This is a new message."));
}
void MainWindow::kyozetu(){
QMessageBox::information(this,tr("Rejected"),tr("Rejected."));
}
void MainWindow::showName(){
QString name=ui->nameEdit->text();
if(name == ""){
name="No name";
}
QMessageBox::information(this,tr("Your name is %1").arg(name),tr("Your name is %1.\nThank you for clicking.").arg(name));
}
void MainWindow::closeEvent(QCloseEvent *e){
qDebug() << "Exit program";
}