-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
67 lines (63 loc) · 2.03 KB
/
main.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
63
64
65
66
67
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
#include <QWidget>
#include <QXmlStreamReader>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *parent=new QWidget();
int x=0;
int y=0;
int width=0;
int height=0;
int windowCount=0;
QString style;
QString content;
MainWindow *newWindow=nullptr;
QFile file("record.xml");
file.open(QIODevice::ReadOnly|QIODevice::Text);
if(file.exists()){
QXmlStreamReader xmlReader(&file);
xmlReader.readNext();
while (!xmlReader.atEnd()) {
if (xmlReader.isStartElement()) {
if (xmlReader.name()=="window") {
windowCount++;
}
else if (xmlReader.name()=="x") {
x=xmlReader.readElementText().toInt();
}
else if (xmlReader.name()=="y") {
y=xmlReader.readElementText().toInt();
}
else if (xmlReader.name()=="width") {
width=xmlReader.readElementText().toInt();
}
else if (xmlReader.name()=="height") {
height=xmlReader.readElementText().toInt();
}
else if (xmlReader.name()=="style") {
style=xmlReader.readElementText();
}
else if (xmlReader.name()=="content") {
content=xmlReader.readElementText();
if (windowCount > 0){
newWindow=new MainWindow(parent);
newWindow->setGeometry(x,y,width,height);
newWindow->setStyleSheet(style);
newWindow->setContentTest(content);
newWindow->show();
}
}
}
xmlReader.readNextStartElement();
}
}
file.close();
if(windowCount==0){
(new MainWindow(parent))->show();
}
return a.exec();
}