-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_window.cpp
More file actions
47 lines (38 loc) · 752 Bytes
/
main_window.cpp
File metadata and controls
47 lines (38 loc) · 752 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
39
40
41
42
43
44
45
46
47
#include "main_window.h"
#include "ui_main.h"
#include <QPainter>
#include <QThread>
#include <iostream>
#include <QGraphicsWidget>
#include <iostream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
c = new Controller(this);
}
MainWindow::~MainWindow()
{
delete ui;
delete c;
}
void MainWindow::paintEvent(QPaintEvent * e) {
QPainter painter(this);
painter.drawImage(0, 0, c->onPaint());
}
void MainWindow::keyPressEvent(QKeyEvent * e) {
if (e == nullptr) {
return;
}
if (e->key() == 81) {
this->close();
return;
}
c->onKeyPressed(e->key());
upd();
}
void MainWindow::upd()
{
this->repaint();
}