PyQt5 自定义可拖动标题栏
将此段代码加入到我的上一篇博客TitleWidget类中即可 实现标题栏的拖动
def getRestoreInfo(self):return self.restorePos, self.restoreSizedef mousePressEvent(self, QMouseEvent):self.isPressed = Trueself.startMovePos = QMouseEvent.globalPos()print(self.startMovePos)def mouseMoveEvent(self, QMouseEvent):if self.isPressed:movePoint = QMouseEvent.globalPos() - self.startMovePoswidgetPos = self.parentWidget().parentWidget().pos()self.startMovePos = QMouseEvent.globalPos()self.parentWidget().parentWidget().move(widgetPos.x() + movePoint.x(), widgetPos.y() + movePoint.y())def mouseReleaseEvent(self, QMouseEvent):self.isPressed = False