#include "loqdialog.h" LoQDialog::LoQDialog(QWidget *parent) : QDialog(parent) { setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_TranslucentBackground); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::Dialog|Qt::FramelessWindowHint //|Qt::Tool ); setWindowModality(Qt::WindowModal); // setWindowFlags(windowFlags() & // ~Qt::WindowContextHelpButtonHint | // Qt::FramelessWindowHint | // Qt::Tool); // setWindowFlags(windowFlags() & // ~Qt::WindowContextHelpButtonHint | // Qt::FramelessWindowHint | // Qt::Tool); } void LoQDialog::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { QRect gRect = this->geometry(); gRect.setWidth(gRect.width() - 10); gRect.setHeight(gRect.height() - 10); gRect.setX(gRect.x() + 5); gRect.setY(gRect.y() + 5); if(gRect.contains(event->globalPos())) { m_winMove = true; m_winOrgPoint = event->globalPos(); m_winWorldPoint = this->frameGeometry().topLeft(); } else { // Resize the window } } } void LoQDialog::mouseMoveEvent(QMouseEvent *event) { //return; if(m_winMove) { if (event->buttons() & Qt::LeftButton) { QPoint relativePos = event->globalPos() - m_winOrgPoint; this->move(m_winWorldPoint + relativePos ); } } } void LoQDialog::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { m_winMove = false; } } void LoQDialog::showEvent(QShowEvent *event) { this->setAttribute(Qt::WA_Mapped); QWidget::showEvent(event); }