How to use mouse to moving windows of not have title bar?
How to use mouse to moving windows of not have title bar?
#include "widget.h"
#include <QMouseEvent>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->setWindowFlags(Qt::FramelessWindowHint);
}
Widget::~Widget()
{
}
void Widget::mousePressEvent(QMouseEvent *event)
{
QPoint winPt = this->pos();
QPoint mousePt = event->globalPos();
_dtPt = mousePt - winPt;
}
void Widget::mouseMoveEvent(QMouseEvent *event)
{
this->move(event->globalPos() - _dtPt);
}
版权声明:本博文属于作者原创或从其他地方学习而来的博文,未经许可不得转载.