本文整理汇总了Python中PyQt5.QtCore.QEvent.MouseMove方法的典型用法代码示例。如果您正苦于以下问题:Python QEvent.MouseMove方法的具体用法?Python QEvent.MouseMove怎么用?Python QEvent.MouseMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QEvent
的用法示例。
在下文中一共展示了QEvent.MouseMove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleEvent
# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseMove [as 别名]
def handleEvent(self, event):
if event.type() == QEvent.MouseButtonPress:
ex, ey = self._normalizeCoordinates(event.windowPos().x(), event.windowPos().y())
e = MouseEvent(MouseEvent.MousePressEvent, ex, ey, self._x, self._y, self._qtButtonsToButtonList(event.buttons()))
self._x = ex
self._y = ey
self.event.emit(e)
elif event.type() == QEvent.MouseMove:
ex, ey = self._normalizeCoordinates(event.windowPos().x(), event.windowPos().y())
e = MouseEvent(MouseEvent.MouseMoveEvent, ex, ey, self._x, self._y, self._qtButtonsToButtonList(event.buttons()))
self._x = ex
self._y = ey
self.event.emit(e)
elif event.type() == QEvent.MouseButtonRelease:
ex, ey = self._normalizeCoordinates(event.windowPos().x(), event.windowPos().y())
e = MouseEvent(MouseEvent.MouseReleaseEvent, ex, ey, self._x, self._y, self._qtButtonsToButtonList(event.button()))
self._x = ex
self._y = ey
self.event.emit(e)
elif event.type() == QEvent.Wheel:
delta = event.angleDelta()
e = WheelEvent(delta.x(), delta.y())
self.event.emit(e)
示例2: eventFilter
# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseMove [as 别名]
def eventFilter(self, widget, event):
if widget is self.viewport():
index = self._last_index
if event.type() == QEvent.MouseMove:
index = self.indexAt(event.pos())
elif event.type() == QEvent.Leave:
index = QModelIndex()
if index != self._last_index:
row = self._last_index.row()
column = self._last_index.column()
item = self.item(row, column)
if item is not None:
self.itemExited.emit(item)
self.cellExited.emit(row, column)
self._last_index = QPersistentModelIndex(index)
return QTableWidget.eventFilter(self, widget, event)
示例3: _click_fake_event
# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseMove [as 别名]
def _click_fake_event(self, click_target: usertypes.ClickTarget,
button: Qt.MouseButton = Qt.LeftButton) -> None:
"""Send a fake click event to the element."""
pos = self._mouse_pos()
log.webelem.debug("Sending fake click to {!r} at position {} with "
"target {}".format(self, pos, click_target))
target_modifiers = {
usertypes.ClickTarget.normal: Qt.NoModifier,
usertypes.ClickTarget.window: Qt.AltModifier | Qt.ShiftModifier,
usertypes.ClickTarget.tab: Qt.ControlModifier,
usertypes.ClickTarget.tab_bg: Qt.ControlModifier,
}
if config.val.tabs.background:
target_modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier
else:
target_modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier
modifiers = typing.cast(Qt.KeyboardModifiers,
target_modifiers[click_target])
events = [
QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
Qt.NoModifier),
QMouseEvent(QEvent.MouseButtonPress, pos, button, button,
modifiers),
QMouseEvent(QEvent.MouseButtonRelease, pos, button, Qt.NoButton,
modifiers),
]
for evt in events:
self._tab.send_event(evt)
QTimer.singleShot(0, self._move_text_cursor)
示例4: hover
# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseMove [as 别名]
def hover(self) -> None:
"""Simulate a mouse hover over the element."""
pos = self._mouse_pos()
event = QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
Qt.NoModifier)
self._tab.send_event(event)
示例5: event
# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseMove [as 别名]
def event(self, event):
if not self.initialized:
return super(BlipDriver, self).event(event)
self.makeCurrent()
if event.type() in [QEvent.MouseMove, QEvent.MouseButtonPress, QEvent.MouseButtonRelease]:
px = 2.0 * (event.x()) / self.width - 1.0
py = 10.0 * (self.height - event.y()) / self.height - 1.0
if event.type() == QEvent.MouseButtonPress and event.button() & Qt.LeftButton:
self.btn_pressed, _ = check_knob(px, py)
if self.btn_pressed is not None:
self.drag_start = event.x(), event.y()
QTimer.singleShot(100, self.updateAPValues)
elif event.type() == QEvent.MouseButtonRelease and event.button() & Qt.LeftButton:
# print px, py
self.btn_pressed = None
col_triangles = 6 * [255, 255, 255, 180]
update_buffer(self.updown.colorbuf, np.array(col_triangles, dtype=np.uint8))
# MCP button clicked?
name, idx = check_btn(px, py)
if name is not None:
self.btn_state[idx] = not self.btn_state[idx]
btn_color = []
for b in self.btn_state:
btn_color += 24 * [255] if b else 24 * [0]
update_buffer(self.btn_leds.colorbuf, np.array(btn_color, dtype=np.uint8))
elif event.type() == QEvent.MouseMove:
if event.buttons() & Qt.LeftButton and self.btn_pressed is not None:
self.rate = float(self.drag_start[1] - event.y()) / self.height
if self.rate > 1e-2:
col_triangles = 3 * [255, 140, 0, 255] + 3 * [255, 255, 255, 180]
elif self.rate < 1e-2:
col_triangles = 3 * [255, 255, 255, 180] + 3 * [255, 140, 0, 255]
else:
col_triangles = 6 * [255, 255, 255, 180]
update_buffer(self.updown.colorbuf, np.array(col_triangles, dtype=np.uint8))
return True
# Mouse-over for knobs
name, self.updownpos = check_knob(px, py)
# ismcp = float(self.height - event.y()) / self.height <= 0.2
return super(BlipDriver, self).event(event)
示例6: eventFilter
# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseMove [as 别名]
def eventFilter(self, obj, event):
"""Reimplemented."""
if self.__popupIsShown and \
event.type() == QEvent.MouseMove and \
self.view().isVisible() and self.__initialMousePos is not None:
diff = obj.mapToGlobal(event.pos()) - self.__initialMousePos
if diff.manhattanLength() > 9 and \
self.__blockMouseReleaseTimer.isActive():
self.__blockMouseReleaseTimer.stop()
# pass through
if self.__popupIsShown and \
event.type() == QEvent.MouseButtonRelease and \
self.view().isVisible() and \
self.view().rect().contains(event.pos()) and \
self.view().currentIndex().isValid() and \
self.view().currentIndex().flags() & Qt.ItemIsSelectable and \
self.view().currentIndex().flags() & Qt.ItemIsEnabled and \
self.view().currentIndex().flags() & Qt.ItemIsUserCheckable and \
self.view().visualRect(self.view().currentIndex()).contains(event.pos()) and \
not self.__blockMouseReleaseTimer.isActive():
model = self.model()
index = self.view().currentIndex()
state = model.data(index, Qt.CheckStateRole)
model.setData(index,
Qt.Checked if state == Qt.Unchecked else Qt.Unchecked,
Qt.CheckStateRole)
self.view().update(index)
self.update()
self.flagChanged.emit(index.row(),state == Qt.Unchecked)
return True
if self.__popupIsShown and event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_Space:
# toogle the current items check state
model = self.model()
index = self.view().currentIndex()
flags = model.flags(index)
state = model.data(index, Qt.CheckStateRole)
if flags & Qt.ItemIsUserCheckable and \
flags & Qt.ItemIsTristate:
state = Qt.CheckState((int(state) + 1) % 3)
elif flags & Qt.ItemIsUserCheckable:
state = Qt.Checked if state != Qt.Checked else Qt.Unchecked
model.setData(index, state, Qt.CheckStateRole)
self.view().update(index)
self.update()
self.flagChanged.emit(index.row(),state != Qt.Unchecked)
return True
# TODO: handle Qt.Key_Enter, Key_Return?
return super(CheckComboBox, self).eventFilter(obj, event)