summaryrefslogtreecommitdiffstats
path: root/src/DragWidget.cpp
blob: 5a651309ed4c005a076fe1761fe795243cd1a539 (plain)
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
#include "DragWidget.h"

DragWidget::DragWidget(QWidget *parent, const char *name, WFlags f) : QWidget(parent,name,f)
{
	dragP=QPoint(0,0);
	drag=false;

}
DragWidget::~DragWidget()
{

}

void DragWidget::mousePressEvent(QMouseEvent *e)
{
	dragP=e->pos();
	gpress=e->globalPos();
	drag=true;

}
void DragWidget::mouseReleaseEvent(QMouseEvent *)
{

	drag=false;
}
void DragWidget::mouseMoveEvent(QMouseEvent *e)
{
	if (!drag) {
		return;
	}
	QPoint curr(e->globalPos().x()-dragP.x(),e->globalPos().y()-dragP.y());
	QWidget::move(curr);
	
}