本文整理汇总了Python中enaml.qt.QtGui.QApplication.startDragDistance方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.startDragDistance方法的具体用法?Python QApplication.startDragDistance怎么用?Python QApplication.startDragDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enaml.qt.QtGui.QApplication
的用法示例。
在下文中一共展示了QApplication.startDragDistance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseMoveEvent
# 需要导入模块: from enaml.qt.QtGui import QApplication [as 别名]
# 或者: from enaml.qt.QtGui.QApplication import startDragDistance [as 别名]
def mouseMoveEvent(self, event):
""" Handle the mouse move event for the tab bar.
This handler will undock the tab if the mouse is held and the
drag leaves the boundary of the container by the application
drag distance amount.
"""
super(QDockTabBar, self).mouseMoveEvent(event)
if not self._has_mouse:
return
pos = event.pos()
if self.rect().contains(pos):
return
x = max(0, min(pos.x(), self.width()))
y = max(0, min(pos.y(), self.height()))
dist = (QPoint(x, y) - pos).manhattanLength()
if dist > QApplication.startDragDistance():
# Fake a mouse release event so that the tab resets its
# internal state and finalizes the animation for the tab.
# The button must be Qt.LeftButton, not event.button().
btn = Qt.LeftButton
mod = event.modifiers()
evt = QMouseEvent(QEvent.MouseButtonRelease, pos, btn, btn, mod)
QApplication.sendEvent(self, evt)
container = self.parent().widget(self.currentIndex())
container.untab(event.globalPos())
self._has_mouse = False
示例2: titleBarMouseMoveEvent
# 需要导入模块: from enaml.qt.QtGui import QApplication [as 别名]
# 或者: from enaml.qt.QtGui.QApplication import startDragDistance [as 别名]
def titleBarMouseMoveEvent(self, event):
""" Handle a mouse move event on the title bar.
Returns
-------
result : bool
True if the event is handled, False otherwise.
"""
state = self.frame_state
if state.press_pos is None:
return False
# If dragging and floating, move the container's position and
# notify the manager of that the container was mouse moved. If
# the container is maximized, it is first restored before.
global_pos = event.globalPos()
if state.dragging:
if self.isWindow():
target_pos = global_pos - state.press_pos
self.manager().drag_move_frame(self, target_pos, global_pos)
return True
# Ensure the drag has crossed the app drag threshold.
dist = (event.pos() - state.press_pos).manhattanLength()
if dist <= QApplication.startDragDistance():
return True
# If the container is already floating, ensure that it is shown
# normal size. The next move event will move the window.
state.dragging = True
if self.isWindow():
state.frame_was_maximized = self.isMaximized()
if state.frame_was_maximized:
coeff = state.press_pos.x() / float(self.width())
self.showNormal()
state.press_pos = _computePressPos(self, coeff)
return True
# Restore a maximized dock item before unplugging.
if state.item_is_maximized:
bar = self.dockItem().titleBarWidget()
coeff = state.press_pos.x() / float(bar.width())
self.showNormal()
state.press_pos = _computePressPos(self, coeff)
# Unplug the container from the layout before floating so
# that layout widgets can clean themselves up when empty.
if not self.unplug():
return False
self.postUndockedEvent()
# Make the container a toplevel frame, update it's Z-order,
# and grab the mouse to continue processing drag events.
self.float()
self.raiseFrame()
margins = self.layout().contentsMargins()
state.press_pos += QPoint(0, margins.top())
state.start_pos = global_pos - state.press_pos
self.move(state.start_pos)
self.show()
self.grabMouse()
self.activateWindow()
self.raise_()
return True