-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextEditorv102.cpp
More file actions
37 lines (30 loc) · 1019 Bytes
/
Copy pathTextEditorv102.cpp
File metadata and controls
37 lines (30 loc) · 1019 Bytes
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
#include "TextEditorv102.h"
#include"Toolbar.h"
#include"TextEditor.h"
TextEditorv102::TextEditorv102(QWidget *parent)
: QMainWindow(parent), textEditor(new TextEditor(this))
{
ui.setupUi(this);
//TextEditor* textEditor = new TextEditor(this);
MenuBar* menuBar = new MenuBar(textEditor,this);
ToolBar* toolbar = new ToolBar(textEditor,this);
addToolBar(toolbar);
setMenuBar(menuBar);
setCentralWidget(textEditor);
}
void TextEditorv102::openFile(const QString& fileName)
{
QFile file("C:\\Users\\malik\\source\\repos\\Dos v1\\" + fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QMessageBox::warning(this, "Error", "Cannot open file: "+fileName + file.errorString());
return;
}
QTextStream in(&file);
QString content = in.readAll();
file.close();
textEditor->setPlainText(content);
setWindowTitle("Text Editor - " + fileName);
}
TextEditorv102::~TextEditorv102()
{}