forked from luckymark/wuziqi2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paintevents.h
55 lines (53 loc) · 1.79 KB
/
paintevents.h
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
#ifndef PAINTEVENTS_H
#define PAINTEVENTS_H
#include <mainwindow.h>
void MainWindow::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
int i,j;
for (i = 0; i < SIZE; i++)
{
p.drawLine(x_o,y_o+i*WIDTH,x_o+WIDTH*(SIZE-1),y_o+i*WIDTH);//GEN GAI
p.drawLine(x_o+i*WIDTH,y_o,x_o+i*WIDTH,y_o+WIDTH*(SIZE-1));
}
QBrush brush;
brush.setStyle(Qt::SolidPattern);
for (i = 0; i < SIZE; i++)
{
for (j = 0; j < SIZE; j++)
{
if (a[i][j] == 1)
{
brush.setColor(Qt::black);
p.setBrush(brush);
p.drawEllipse(QPoint(x_o+i*WIDTH,y_o+j*WIDTH), 15, 15);
}
else if (a[i][j] == 2)
{
brush.setColor(Qt::white);
p.setBrush(brush);
p.drawEllipse(QPoint(x_o+i*WIDTH,y_o+j*WIDTH), 15, 15);
}
// else if (a[i][j] == 3)
// {
// brush.setColor(Qt::red);
// p.setBrush(brush);
// p.drawEllipse(QPoint((i + 1) * 40, (j + 1) * 40), 15, 15);
// }
// else if (a[i][j] == 4)
// {
// brush.setColor(Qt::blue);
// p.setBrush(brush);
// p.drawEllipse(QPoint((i + 1) * 40, (j + 1) * 40), 15, 15);
// }
// else if (a[i][j] == 5)
// {
// brush.setColor(Qt::yellow);
// p.setBrush(brush);
// p.drawEllipse(QPoint((i + 1) * 40, (j + 1) * 40), 15, 15);
// }
}
}
}
#endif // PAINTEVENTS_H