-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (45 loc) · 1.18 KB
/
Copy pathmain.cpp
File metadata and controls
61 lines (45 loc) · 1.18 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
#include "SizeGrip.h"
#include <QtWidgets/QApplication>
#include "QSizeGrip"
#include "QVBoxLayout"
#include "qevent.h"
class MySizeGrip : public QWidget{
public:
MySizeGrip():QWidget(nullptr, Qt::FramelessWindowHint){
setLayout(new QVBoxLayout);
sizegrip = new QSizeGrip(this);
layout()->addWidget(sizegrip);
}
QSizeGrip* sizegrip;
bool isPressed = false;
QPointF orgin;
QPoint windowPos;
protected:
void mousePressEvent(QMouseEvent* event) override
{
isPressed = true;
orgin = event->screenPos();
windowPos = pos();
}
void mouseMoveEvent(QMouseEvent* event) override
{
if (isPressed) {
// setGeometry(QRect{ QPoint((windowPos + event->screenPos() - orgin).toPoint()), geometry().size() });
move((windowPos + event->screenPos() - orgin).toPoint());
}
}
void mouseReleaseEvent(QMouseEvent* event) override
{
isPressed = false;
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// SizeGrip w;
// w.show();
MySizeGrip sizegrip;
sizegrip.resize(300, 300);
sizegrip.show();
return a.exec();
}