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


posted @ 2017-07-08 07:48  [0]  阅读(174)  评论(0编辑  收藏  举报