-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
102 lines (80 loc) · 1.87 KB
/
mainwindow.cpp
File metadata and controls
102 lines (80 loc) · 1.87 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent)
{
resize(250, 250);
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
}
void MainWindow::mousePressEvent(QMouseEvent *event) {
m_nMouseClick_X_Coordinate = event->position().x();
m_nMouseClick_Y_Coordinate = event->position().y();
}
void MainWindow::mouseMoveEvent(QMouseEvent *event) {
move(event->globalPosition().x()-m_nMouseClick_X_Coordinate,event->globalPosition().y()-m_nMouseClick_Y_Coordinate);
}
QSize MainWindow::minimumSizeHint() const
{
return QSize(100, 100);
}
//! [1]
//! [2]
QSize MainWindow::sizeHint() const
{
return QSize(400, 200);
}
//! [2]
//! [3]
void MainWindow::setShape(Shape shape)
{
this->shape = shape;
update();
}
//! [3]
//! [4]
void MainWindow::setPen(const QPen &pen)
{
this->pen = pen;
update();
}
//! [4]
//! [5]
void MainWindow::setBrush(const QBrush &brush)
{
this->brush = brush;
update();
}
//! [5]
//! [6]
void MainWindow::setAntialiased(bool antialiased)
{
this->antialiased = antialiased;
update();
}
//! [6]
//! [7]
void MainWindow::setTransformed(bool transformed)
{
this->transformed = transformed;
update();
}
//! [7]
//! [8]
void MainWindow::paintEvent(QPaintEvent * /* event */)
{
QRect rect(10, 10, 80, 80);
QPainterPath path;
QPainter painter(this);
painter.setPen(pen);
painter.setBrush(brush);
if (antialiased)
painter.setRenderHint(QPainter::Antialiasing, true);
painter.save();
painter.drawRect(rect);
painter.setRenderHint(QPainter::Antialiasing, false);
painter.setPen(palette().dark().color());
painter.setBrush(Qt::NoBrush);
painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
}
MainWindow::~MainWindow()
{
}