Repository navigation
Expand file tree
/
Copy pathdialog.cpp
More file actions
65 lines (55 loc) · 1.33 KB
/
Copy pathdialog.cpp
File metadata and controls
65 lines (55 loc) · 1.33 KB
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
63
64
65
#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_btnLoad_clicked()
{
QFile file(":/documents/files/files/file.txt");
if(!file.exists())
{
QMessageBox::critical(this,"File not found","Sorry, we could not find that file!");
return;
}
if(!file.open(QIODevice::ReadOnly))
{
QMessageBox::critical(this,"Error",file.errorString());
return;
}
QTextStream stream(&file);
ui->plainTextEdit->setPlainText(stream.readAll());
file.close();
}
void Dialog::on_btnSave_clicked()
{
QFile file(":/documents/files/files/file.txt");
if(!file.exists())
{
QMessageBox::critical(this,"File not found","Sorry, we could not find that file!");
return;
}
if(!file.isWritable())
{
QMessageBox::critical(this,"Non_Writeable","Can not write to file!!!");
return;
}
else
{
QMessageBox::information(this,"Writeable","Can write to file!!!");
}
if(!file.open(QIODevice::WriteOnly))
{
QMessageBox::critical(this,"Error",file.errorString());
return;
}
QTextStream stream(&file);
stream << ui->plainTextEdit->toPlainText();
file.close();
}