FramelessWindowHint removes the abbility to drag/move the window
Solved
General and Desktop
-
So as the title says when using setWindowFlag(Qt::FramelessWindowHint); it also removes the abbility to drag/move the window!
by searching i found this here on this Qt Forum but it's from 2013 and i suspect it's old as i get some errors when trying this code
private: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); int m_nMouseClick_X_Coordinate; int m_nMouseClick_Y_Coordinate; And this to .cpp file: void MainWindow::mousePressEvent(QMouseEvent *event) { m_nMouseClick_X_Coordinate = event->x(); m_nMouseClick_Y_Coordinate = event->y(); } void MainWindow::mouseMoveEvent(QMouseEvent *event) { move(event->globalX()-m_nMouseClick_X_Coordinate,event->globalY()-m_nMouseClick_Y_Coordinate); }
errors i get is
Code: m_nMouseClick_X_Coordinate = event->x(); m_nMouseClick_Y_Coordinate = event->y(); move(event->globalX()-m_nMouseClick_X_Coordinate,event->globalY()-m_nMouseClick_Y_Coordinate); Error: member access into incomplete type 'QMouseEvent'
-
Hi
Yes when removing the caption, one can no longer drag it around.To fix you compile error do
#include "QMouseEvent"You also must add resize if needed.
One of the better version of this, i know is
https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle