-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsole.cpp
More file actions
39 lines (34 loc) · 849 Bytes
/
Copy pathConsole.cpp
File metadata and controls
39 lines (34 loc) · 849 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
38
#include "Console.h"
#include <QKeyEvent>
#include <QTextLine>
#include <QTextCursor>
Console::Console(QWidget *parent) : QTextEdit(parent)
{
}
void Console::clearCon()
{
this->clear();
}
void Console::write(QString msg)
{
this->clear();
this->append(msg);
}
void Console::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Backspace)
return;
if (event->key() == Qt::Key_Delete)
return;
if (this->textCursor().hasSelection())
return;
if (event->key() == Qt::Key_Return) {
QTextCursor cursor = this->textCursor();
cursor.movePosition(QTextCursor::End);
cursor.select(QTextCursor::LineUnderCursor);
QString lastLine = cursor.selectedText();
this->text = lastLine;
newLineWritten(lastLine);
}
QTextEdit::keyPressEvent(event);
}