summaryrefslogtreecommitdiffstats
path: root/src/DragWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/DragWidget.cpp')
-rw-r--r--src/DragWidget.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/DragWidget.cpp b/src/DragWidget.cpp
new file mode 100644
index 0000000..5a65130
--- /dev/null
+++ b/src/DragWidget.cpp
@@ -0,0 +1,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);
+
+}
+