MCPcopy Create free account
hub / github.com/PyQt5/PyQt / mousePressEvent

Method mousePressEvent

Demo/WeltHideWindow.py:82–88  ·  view source on GitHub ↗

鼠标按下事件,需要记录下坐标self._pos 和 是否可移动self._canMove

(self, event)

Source from the content-addressed store, hash-verified

80 self.closeBtn.setMaximumSize(24, 24)
81
82 def mousePressEvent(self, event):
83 """鼠标按下事件,需要记录下坐标self._pos 和 是否可移动self._canMove"""
84 super(WeltHideWindow, self).mousePressEvent(event)
85 if event.button() == Qt.LeftButton:
86 self._pos = event.globalPos() - self.pos()
87 # 当窗口最大化或者全屏时不可移动
88 self._canMove = not self.isMaximized() or not self.isFullScreen()
89
90 def mouseMoveEvent(self, event):
91 """鼠标移动事件,动态调整窗口位置"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected