You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kvkbd/src/DragWidget.cpp

36 lines
540 B

#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);
}