-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.cpp
62 lines (41 loc) · 1.08 KB
/
form.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "form.h"
#include "ui_form.h"
Form::Form(QWidget *parent) :
QDialog(parent),
ui(new Ui::Form)
{
ui->setupUi(this);
this->resize(600,600);
}
Form::~Form()
{
delete ui;
}
void Form::on_pushButton_clicked()
{
path = QFileDialog::getOpenFileName(this,"选择存档","C:/Qt Game/游戏存档");
QFile file(path);
file.open(QIODevice::ReadOnly);
QByteArray array = file.readAll();
ui->textEdit->setText(array);
file.close();
}
void Form::on_pushButton_2_clicked()
{
QFile file(path);
file.open(QIODevice::WriteOnly);
QString text = ui->textEdit->toPlainText();
file.write(text.toUtf8());
file.close();
this->close();
}
void Form::on_pushButton_3_clicked()
{
path = QFileDialog::getSaveFileName(this,"存档","C:/Qt Game/游戏存档/请给存档命名.txt","*.txt");
QFile file(path);
file.open(QIODevice::WriteOnly);
QString text = ui->textEdit->toPlainText();
file.write(text.toUtf8());
file.close();
this->close();
}