I managed to remove the borders from my main window but now I can not move it with the mouse.
This is what I used for it:
self.setWindowFlags((Qt.FramelessWindowHint))
How can I move it again without the edges?
I managed to remove the borders from my main window but now I can not move it with the mouse.
This is what I used for it:
self.setWindowFlags((Qt.FramelessWindowHint))
How can I move it again without the edges?
Overwrite the following methods Source :
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self, event):
if event.buttons() == Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
I have a project that does what you want, you can take it as an example, I use it in the Background class link :
Here I put all the available options listed in the documentation :
Qt::MSWindowsFixedSizeDialogHint;
Qt::X11BypassWindowManagerHint;
Qt::FramelessWindowHint;
Qt::NoDropShadowWindowHint;
Qt::WindowTitleHint;
Qt::WindowSystemMenuHint;
Qt::WindowMinimizeButtonHint;
Qt::WindowMaximizeButtonHint;
Qt::WindowCloseButtonHint;
Qt::WindowContextHelpButtonHint;
Qt::WindowShadeButtonHint;
Qt::WindowStaysOnTopHint;
Qt::WindowStaysOnBottomHint;
Qt::CustomizeWindowHint;
In your specific case I understand that you want to use several flags at the same time to get what you want. For example, in this response expose:
If the window is a widget:
w.setWindowFlags(Qt::Widget | Qt::FramelessWindowHint | Qt::CustomizeWindowHint);
If it's a normal Window:
w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint);
If it's a dialog :
w.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::CustomizeWindowHint);