-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframelesswindow.cpp
51 lines (34 loc) · 994 Bytes
/
framelesswindow.cpp
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
#include "framelesswindow.h"
#include <QDebug>
#include <QtMath>
FramelessWindow::FramelessWindow()
: mousePressed( false )
{
setFlags( Qt::FramelessWindowHint
| Qt::MacWindowToolBarButtonHint
| Qt::WindowMinimizeButtonHint
| Qt::WindowMaximizeButtonHint );
}
FramelessWindow::~FramelessWindow()
{
}
void FramelessWindow::mouseMoveEvent( QMouseEvent *event )
{
if ( mousePressed ) {
QPoint newPoint( x() + ( event->x() - clickPosition.x() ), y() + ( event->y() - clickPosition.y() ) );
setPosition(newPoint);
}
QQuickWindow::mouseMoveEvent( event );
}
void FramelessWindow::mouseReleaseEvent( QMouseEvent *event )
{
mousePressed = false;
QQuickWindow::mouseReleaseEvent( event );
}
void FramelessWindow::mousePressEvent( QMouseEvent *event )
{
mousePressed = true;
clickPosition.setX( event->x() );
clickPosition.setY( event->y() );
QQuickWindow::mousePressEvent( event );
}