I am trying to making draggable frameless qdialog in pyqt6, but it doesnt work as intended.
def _is_in_top_bar(self, pos):
"""Check if the click is within the top bar."""
return 0 <= pos.y() <= 50 # Adjust based on top bar height
def mousePressEvent(self, event):
if event.button() == qt.MouseButton.LeftButton and self._is_in_top_bar(event.pos()):
self._is_dragging = True
self._drag_position = event.globalPosition().toPoint() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self, event):
if self._is_dragging:
self.move(event.globalPosition().toPoint() - self._drag_position)
event.accept()
def mouseReleaseEvent(self, event):
if event.button() == qt.MouseButton.LeftButton:
self._is_dragging = False
event.accept()
what can I do?