def mouseReleaseEvent(self, ev: QtGui.QMouseEvent): if ev.button() == QtCore.Qt.LeftButton: self.is_pan = False self.setCursor(QtCore.Qt.ArrowCursor) ev.accept() else: ev.ignore()
def mousePressEvent(self, event): if event.button() == self.fMiddleButton: self.fPanning = True self.setDragMode(QGraphicsView.ScrollHandDrag) event = QMouseEvent(event.type(), event.pos(), Qt.LeftButton, Qt.LeftButton, event.modifiers()) QGraphicsView.mousePressEvent(self, event)
def mousePressEvent(self, event): if event.button() == Qt.RightButton: # Rewrite the mouse event to a left button event so the cursor is # moved to the location of the pointer. event = QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QTextEdit.mousePressEvent(self, event)
def mousePressEvent(self, event: QMouseEvent): if self.window().is_dirty(): veto = self.window().central_widget.promptToSave() if not veto: QTreeWidget.mousePressEvent(self, event) QTreeWidget.mouseReleaseEvent(self, event) else: event.ignore() else: QTreeWidget.mousePressEvent(self, event)
def mouseMoveEvent(self, event: QtGui.QMouseEvent): if self.leftButtonPressed: moveWidth = (event.pos().x() - self.lastPositionOfMouse.x())*self.scale_factor moveHeight = (event.pos().y() - self.lastPositionOfMouse.y())*self.scale_factor self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) new_center = QtCore.QPoint(int(self.viewport().rect().width() / 2 -moveWidth) , int(self.viewport().rect().height() / 2 -moveHeight)) #mapToScene 实现映射 self.centerOn(self.mapToScene(new_center)) self.lastPositionOfMouse = event.pos() self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)#?
def customMouseRelease(self, event: QMouseEvent): """Parses a :meth:`mouseReleaseEvent` from view, calling the appropriate tool method as necessary. Deletes ``_move_idx`` if necessary. """ tool_method_name = self._getActiveTool().methodPrefix() + "MouseRelease" if hasattr(self, tool_method_name): # if the tool method exists modifiers = event.modifiers() x = event.pos().x() getattr(self, tool_method_name)(modifiers, x) # call tool method if hasattr(self, '_move_idx'): del self._move_idx
def mousePressEvent(self, event): """ Select misspelled word after right click otherwise left clik + right click is needed. Originally from John Schember spellchecker """ if event.button() == Qt.RightButton: # Rewrite the mouse event to a left button event so the cursor is # moved to the location of the pointer. event = QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QTextEdit.mousePressEvent(self, event)
def customMouseRelease(self, event: QMouseEvent): """Parses a GraphicsView :meth:`mouseReleaseEvent` to extract strand_set and base index, forwarding them to approproate tool method as necessary. Args: event: Description """ tool = self._getActiveTool() tool_method_name = tool.methodPrefix() + "MouseRelease" if hasattr(self, tool_method_name): getattr(self, tool_method_name)(self._last_strand_set, self._last_idx) else: event.setAccepted(False)
def customMouseRelease(self, event: QMouseEvent): """Parses a mouseReleaseEvent, calling the approproate tool method as necessary. Deletes _move_idx if necessary. Args: event: Description """ tool_method_name = self._getActiveTool().methodPrefix() + "MouseRelease" if hasattr(self, tool_method_name): # if the tool method exists modifiers = event.modifiers() x = event.pos().x() getattr(self, tool_method_name)(modifiers, x) # call tool method if hasattr(self, '_move_idx'): del self._move_idx
def mouseMoveEvent(self, ev: QtGui.QMouseEvent): if self.is_pan: self.goompy.move(self.coords[0] - ev.x(), self.coords[1] - ev.y()) self.update_map_background() self.coords = ev.x(), ev.y() ev.accept() else: ev.ignore()
def mouseMoveEvent(self, event: QMouseEvent): """Must override :meth:`mouseMoveEvent` of :class:`QGraphicsView` to allow ``ScrollHandDrag`` due to the fact that events are intercepted breaks this feature. """ if self._transform_enable: if self.dragMode() == self._yes_drag: # Add stuff to handle the pan event posf = event.localPos() xf = posf.x() yf = posf.y() factor = self.transform().m11() transform = self.scene_root_item.transform() transform.translate((xf - self._x0)/factor, (yf - self._y0)/factor) self.scene_root_item.setTransform(transform) self._x0 = xf self._y0 = yf elif self._dolly_zoom_enable: self.dollyZoom(event) # adding this allows events to be passed to items underneath QGraphicsView.mouseMoveEvent(self, event)
def mousePressEvent(self, event): if event.button() == QtCore.Qt.LeftButton and self.draggin_idx == -1: point = self._get_point(event) #print(point) event = QMouseEvent(QtCore.QEvent.MouseButtonPress, event.pos(), QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier) self.center = event.pos() dist = self.points - point #print('dist=',dist) dist = dist[:,0]**2 + dist[:,1]**2 dist[dist>self.DELTA] = np.inf #obviate the distances above DELTA if dist.min() < np.inf: self.draggin_idx = dist.argmin() #print(self.center.x(),self.center.y()) self.update()
def mouseReleaseEvent(self, event: QMouseEvent): if self.scene() is None: return cursor = self.cursor().shape() if cursor == Qt.ClosedHandCursor: self.grab_start = None self.setCursor(Qt.OpenHandCursor) elif self.separation_area_moving: y_sep = self.mapToScene(event.pos()).y() y = self.sceneRect().y() h = self.sceneRect().height() if y_sep < y: y_sep = y elif y_sep > y + h: y_sep = y + h self.scene().draw_sep_area(y_sep) self.sep_area_moving.emit(y_sep) self.separation_area_moving = False self.y_sep = y_sep self.sep_area_changed.emit(-y_sep) self.unsetCursor() self.selection_area.finished = True self.selection_area.resizing = False self.emit_selection_size_changed() self.emit_selection_start_end_changed()
def mousePressEvent(self, event: QMouseEvent): if self.scene() is None: return cursor = self.cursor().shape() has_shift_modifier = event.modifiers() == Qt.ShiftModifier is_in_shift_mode = (has_shift_modifier and self.hold_shift_to_drag) \ or (not has_shift_modifier and not self.hold_shift_to_drag) \ and cursor != Qt.SplitHCursor and cursor != Qt.SplitVCursor if event.buttons() == Qt.LeftButton and is_in_shift_mode: self.setCursor(Qt.ClosedHandCursor) self.grab_start = event.pos() elif event.buttons() == Qt.LeftButton: if self.is_pos_in_separea(self.mapToScene(event.pos())): self.separation_area_moving = True self.setCursor(Qt.SplitVCursor) elif self.selection_area.is_empty or self.selection_area.selected_edge is None: # Create new selection self.mouse_press_pos = event.pos() self.mouse_pos = event.pos() scene_pos = self.mapToScene(self.mouse_press_pos) self.__set_selection_area(x=scene_pos.x(), y=scene_pos.y(), w=0, h=0) self.selection_area.finished = False elif self.selection_area.selected_edge is not None: self.selection_area.resizing = True
def mouseDoubleClickEvent(self, event: QMouseEvent): idx = self.indexAt(event.pos()) if not idx.isValid(): return tx_item = self.tx_item_from_proxy_row(idx.row()) if self.hm.flags(self.model().mapToSource(idx)) & Qt.ItemIsEditable: super().mouseDoubleClickEvent(event) else: self.show_transaction(tx_item['txid'])
def mousePressEvent(self, event: QMouseEvent): """ Click on mouse button :param event: mouse event """ if event.button() == Qt.LeftButton: # trigger scene signal self.scene().node_clicked.emit(self.metadata)
def mousePressEvent(self, ev: QtGui.QMouseEvent): if ev.button() == QtCore.Qt.LeftButton: self.is_pan = True self.setCursor(QtCore.Qt.ClosedHandCursor) self.coords = ev.x(), ev.y() ev.accept() else: ev.ignore()
def mousePressEvent(self, event: QMouseEvent): """docstring for mousePressEvent""" if self._transform_enable and qApp.keyboardModifiers(): which_buttons = event.buttons() if which_buttons in [self._button_pan, self._button_pan_alt]: self._panEnable() posf = event.localPos() self._x0 = posf.x() self._y0 = posf.y() elif which_buttons == self._button_zoom: self._dolly_zoom_enable = True self._last_scale_factor = 0 # QMouseEvent.y() returns the position of the mouse cursor # relative to the widget self._y0 = event.localPos().y() else: QGraphicsView.mousePressEvent(self, event) else: QGraphicsView.mousePressEvent(self, event)
def mouseReleaseEvent(self, event: QMouseEvent): button = event.button() if button == Qt.LeftButton: if self._mouse_over_planet_name: # logger.debug('planet name click') self.setCursor(Qt.ArrowCursor) # sometimes cursor is not restored to arrow self.requestOpenPlanet.emit(self._planet.planet_id) elif self._mouse_over_planet_coords: # logger.debug('planet coords click') self.setCursor(Qt.ArrowCursor) # sometimes cursor is not restored to arrow self.requestOpenGalaxy.emit(self._planet.coords)
def customMouseRelease(self, event: QMouseEvent): """Parses a :class:`QMouseEvent` to extract strandSet and base index, forwarding them to approproate tool method as necessary. Args: event: """ tool_method_name = self._getActiveTool().methodPrefix() + "MouseRelease" if hasattr(self, tool_method_name): idx = int(floor((event.pos().x()) / _BASE_WIDTH)) getattr(self, tool_method_name)(idx)
def mouseMoveEvent(self, event: QMouseEvent): super(PlanetSidebarWidget, self).mouseMoveEvent(event) # QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. mx = event.x() my = event.y() # global_mouse_pos = event.globalPos() fields_pb_h = self._pb_texture.height() # remember prev prev_mouse_over_planet_name = self._mouse_over_planet_name prev_mouse_over_planet_coords = self._mouse_over_planet_coords self._mouse_over_planet_name = False self._mouse_over_planet_coords = False self._mouse_over_planet_fields = False # calculate if (my >= 3) and (my <= 23): self._mouse_over_planet_name = True if (my >= 24) and (my <= 35): self._mouse_over_planet_coords = True if (my >= self.height()-fields_pb_h) and (my <= self.height()): self._mouse_over_planet_fields = True # detect change change = False if prev_mouse_over_planet_name != self._mouse_over_planet_name: change = True if prev_mouse_over_planet_coords != self._mouse_over_planet_coords: change = True self._tt.hide() if change: if self._mouse_over_planet_name or self._mouse_over_planet_coords: self.setCursor(Qt.PointingHandCursor) else: self.setCursor(Qt.ArrowCursor) if self._mouse_over_planet_name: self._tt.show_tt(0, 40, self.tr('Go to planet')) if self._mouse_over_planet_coords: self._tt.show_tt(0, 40, self.tr('Go to galaxy')) if self._mouse_over_planet_fields: self._tt.show_tt(0, 40, self.tr('Field: {0}/{1}').format( self._planet.fields_busy, self._planet.fields_total)) self.update()
def dollyZoom(self, event: QMouseEvent): """docstring for dollyZoom""" # QMouseEvent.y() returns the position of the mouse cursor relative # to the widget yf = event.y() denom = abs(yf - self._y0) if denom > 0: scale_factor = (self.height() / 2) % denom if self._last_scale_factor != scale_factor: self._last_scale_factor = scale_factor # zoom in if mouse y position is getting bigger if yf - self._y0 > 0: self.safeScale(yf - self._y0) # end else else: # else id smaller zoom out self.safeScale(yf - self._y0)
def _redirectEvent(self, event, callback, transmuteMouseEvent=False): if transmuteMouseEvent: # construct a new event with pos in canvas coordinates canvasPos = self.mapToCanvas(event.localPos()) event = QMouseEvent( event.type(), canvasPos, event.windowPos(), event.screenPos(), event.button(), event.buttons(), event.modifiers() ) callback(event)
def customMouseRelease(self, event: QMouseEvent): """ Args: event: Description """ self.selectionbox.setParentItem(self.viewroot) self.selectionbox.hide() self.selectionbox.resetTransform() self._drag_enable = False # now do stuff if not (self._r0 == 0 and self._r == 0): modifiers = event.modifiers() self.selectionbox.processSelectedItems(self._r0, self._r, modifiers) # end if self._r0 = 0 # reset self._r = 0 # reset self.setFocus() # needed to get keyPresses post a move self._added_to_press_list = False
def mouseReleaseEvent(self, ev: QtGui.QMouseEvent): pos = ev.pos() glBindBuffer(GL_SHADER_STORAGE_BUFFER, self.click_buffer) # Map the GPU-side shader-storage-buffer on the application, allowing for write-only access ssb = cast(glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY), POINTER(SSB)).contents # Save the clicked location information ssb.clicked_x, ssb.clicked_y = pos.x(), pos.y() # Initialize fields ssb.pick_z = float('-inf') # Initially -infty ssb.pick_lock, ssb.pick_id = 0, -1 # Initially UNLOCKED (c.f., [email protected]) if logging: print('float.min: {0}'.format(sys.float_info.min)) print('Mouse released: pos: ({0}, {1}), z: {2}'.format(ssb.clicked_x, ssb.clicked_y, ssb.pick_z)) # Unmap the SSB glUnmapBuffer(GL_SHADER_STORAGE_BUFFER) # Tell the next rendering cycle to perform pick-identification glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0) self.should_handle_pick = True
def mousePressEvent(self, event): event = QMouseEvent(event) if event.button() == Qt.LeftButton: plottable = self.plottableAt(event.pos()) if plottable is not None: x = self.xAxis.pixelToCoord(event.pos().x()) y = self.yAxis.pixelToCoord(event.pos().y()) bar = self.plottableBarsAt(event.pos()) graph = self.plottableGraphAt(event.pos()) if bar: data = QCPBarData(bar.data()[4.0]) y = data.value QToolTip.showText(event.globalPos(), QCoreApplication.translate('MousePlot', '<table>' '<tr>' '<th colspan="2">%s</th>' '</tr>' '<tr>' '<td>%s rub.</td>' '</tr>' '</table>') % (plottable.name(), str(y))) elif graph: labels = self.xAxis.tickVectorLabels() label_x = str(labels[int(x)]) y = round(y, 2) if not label_x == '': QToolTip.showText(event.globalPos(), QCoreApplication.translate('MousePlot', '<table>' '<tr>' '<th colspan="2">%s</th>' '</tr>' '<tr>' '<td>%s: %s rub.</td>' '</tr>' '</table>') % (plottable.name(), label_x, str(y))) super().mousePressEvent(event)
def mouseReleaseEvent(self, event: QMouseEvent): """If panning, stop. If handles were pressed, release them.""" if self._transform_enable: # QMouseEvent.button() returns the button that triggered the event which_button = event.button() if which_button in [self._button_pan, self._button_pan_alt]: self._panDisable() elif which_button == self._button_zoom: self._dolly_zoom_enable = False else: return QGraphicsView.mouseReleaseEvent(self, event) # end if else: if len(self._press_list): # Notify any pressed items to release # event_pos = event.pos() for item in self._press_list: item.customMouseRelease(event) self._press_list = [] # end if if self._selection_lock: self._selection_lock.processPendingToAddList() return QGraphicsView.mouseReleaseEvent(self, event)
def _click(self, event: QtGui.QMouseEvent) -> None: workspace_widget = self._container.window().childAt(event.globalPos()) workspace = self._widget_to_workspace(workspace_widget) with self.exception_guard(): run(["bspc", "desktop", "-f", workspace.name or "?"])
def mouseMoveEvent(self, event: QMouseEvent): if isinstance(self.scene(), GridScene): freq = self.scene().get_freq_for_pos(int(self.mapToScene(event.pos()).x())) if freq is not None: QToolTip.showText(self.mapToGlobal(event.pos()), "Tune to:" + Formatter.big_value_with_suffix(freq), None, QRect(), 10000)
def mousePressEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == QtCore.Qt.LeftButton: if self.childAt(evt.pos()) == self.thumbnail.widget(): self.is_selected = not self.is_selected
def mouseMoveEvent(self, event: QMouseEvent): self.pos = event.pos() self.update()
def mouseMoveEvent(self, e: QtGui.QMouseEvent): # 重写移动事件 self._endPos = e.pos() - self._startPos self.move(self.pos() + self._endPos)
def mouseReleaseEvent(self, e: QMouseEvent): self._move_mode = False self._mouse_pos = (e.x(), e.y()) self._mouse_gpos = (e.globalX(), e.globalY()) super().mouseReleaseEvent(e)
def mouseReleaseEvent(self, q_mouse_event: QMouseEvent): if self.click_handler() and q_mouse_event.button() == Qt.LeftButton: self.set_select(not self.selected)
def mouseMoveEvent(self, event: QMouseEvent): if self.scene() is None: return cursor = self.cursor().shape() if self.grab_start is not None: move_x = self.grab_start.x() - event.pos().x() self.horizontalScrollBar().setValue( self.horizontalScrollBar().value() + move_x) if self.move_y_with_drag: move_y = self.grab_start.y() - event.pos().y() self.verticalScrollBar().setValue( self.verticalScrollBar().value() + move_y) self.grab_start = event.pos() return if self.separation_area_moving: y_sep = self.mapToScene(event.pos()).y() y = self.sceneRect().y() h = self.sceneRect().height() if y < y_sep < y + h: self.scene().draw_sep_area(y_sep, show_symbols=True) self.sep_area_moving.emit(y_sep) elif self.is_pos_in_separea(self.mapToScene(event.pos())): self.setCursor(Qt.SplitVCursor) elif cursor == Qt.SplitVCursor and self.has_horizontal_selection: self.unsetCursor() if self.selection_area.finished and not self.selection_area.resizing: pos = self.mapToScene(event.pos()) roi_edge = self.selection_area.get_selected_edge( pos, self.transform()) if roi_edge is None: if (cursor == Qt.SplitHCursor and self.has_horizontal_selection) \ or (cursor == Qt.SplitVCursor and not self.has_horizontal_selection): self.unsetCursor() return elif roi_edge == 0 or roi_edge == 1: if self.has_horizontal_selection: self.setCursor(Qt.SplitHCursor) else: self.setCursor(Qt.SplitVCursor) if event.buttons() == Qt.LeftButton and self.selection_area.resizing: if self.selection_area.selected_edge == 0: start = self.mapToScene(event.pos()) self.__set_selection_area(x=start.x(), y=start.y()) if self.has_horizontal_selection: self.scroll_mouse(start.x()) return if self.selection_area.selected_edge == 1: start = QPoint(self.selection_area.x, self.selection_area.y) end = self.mapToScene(event.pos()) self.__set_selection_area(w=end.x() - start.x(), h=end.y() - start.y()) if self.has_horizontal_selection: self.scroll_mouse(end.x()) return if self.mouse_press_pos is None: return self.mouse_pos = event.pos() if event.buttons( ) == Qt.LeftButton and not self.selection_area.finished: start = self.mapToScene(self.mouse_press_pos) end = self.mapToScene(self.mouse_pos) self.__set_selection_area(w=end.x() - start.x(), h=end.y() - start.y()) if self.has_horizontal_selection: self.scroll_mouse(end.x())
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)
def _create_mouse_event(button, modifier=Qt.NoModifier): return QMouseEvent(QEvent.MouseButtonPress, QPoint(0, 0), QPoint(0, 0), button, button, modifier)
def mousePressEvent(self, event: QtGui.QMouseEvent): if event.button() == QtCore.Qt.LeftButton: self.eventQueue.put({'EVENT': 'BOXCLICK', 'ARGS': [self.item_name]})
def mousePressEvent(self, e: QtGui.QMouseEvent) -> None: if e.button() == QtCore.Qt.LeftButton: self.pressed = True self.update() super().mousePressEvent(e)
def mouseMoveEvent(self, event: QMouseEvent): repaint = False mx, my = self.posToWorldPos(event.x(), event.y()) self.onCursorChange.emit(mx, my) if self.scroll_enabled and (event.buttons() & Qt.MiddleButton): self.x_offset -= self.prevX - event.x() self.y_offset -= self.prevY - event.y() repaint = True if self.clicked_object is None: if self.scroll_enabled and (event.buttons() & Qt.LeftButton): self.mouse_moved = True self.x_offset -= self.prevX - event.x() self.y_offset -= self.prevY - event.y() repaint = True else: if not self.move_objects: x, y = self.click_pos distance = math.hypot(x-event.x(), y-event.y()) if distance > self.min_move_distance: self.move_objects = True click_x, click_y = self.posToWorldPos(x, y) self.moved_rest = (mx - click_x, my - click_y) else: rest_x, rest_y = self.moved_rest cur_pos = self.posToWorldPos(event.x(), event.y()) prev_pos = self.posToWorldPos(self.prevX, self.prevY) nx, ny = tuple(map(sub, cur_pos, prev_pos)) snap = self.snap self.moved_rest = (math.fmod(rest_x + nx, snap), math.fmod(rest_y + ny, snap)) move_x, move_y = (( rest_x + nx - self.moved_rest[0]) / snap, (rest_y + ny - self.moved_rest[1]) / snap) for o in self.selectedObjects: o.x += move_x * snap o.y += move_y * snap self.emitSelectedObjects() repaint = True # self.scroll_view = True self.prevX = event.x() self.prevY = event.y() if repaint: self.repaint()
def mousePressEvent(self, event: QMouseEvent): self.setFocus(Qt.ActiveWindowFocusReason) self.prevX = event.x() self.prevY = event.y() if event.buttons() & Qt.LeftButton: self.zoom_enabled = False self.left_clicked = True (mx, my) = self.posToWorldPos(event.x(), event.y()) obj = self.state.getClickedObject(mx, my) self.clicked_object = obj if obj is not None: self.scroll_enabled = False if event.modifiers() & Qt.ControlModifier: self.control_pressed = True if obj in self.selectedObjects: obj.selected = False self.selectedObjects.remove(obj) else: obj.selected = True self.selectedObjects.append(obj) else: if obj not in self.selectedObjects: for o in self.selectedObjects: o.selected = False self.selectedObjects.clear() obj.selected = True self.selectedObjects.append(obj) self.click_pos = (event.x(), event.y()) elif event.buttons() & Qt.RightButton: (mx, my) = self.posToWorldPos(event.x(), event.y()) obj = self.state.getClickedObject(mx, my) if isinstance(obj, Node): for o in self.selectedObjects: if isinstance(o, Node): self.state.toggleMember(obj, o, self.selected_material) self.emitSelectedObjects() self.repaint()
def mouseMoveEvent(self, e: QMouseEvent): # 重写移动事件 if self._isTracking: self._endPos = e.pos() - self._startPos self.move(self.pos() + self._endPos)
def mousePressEvent(self, event: QMouseEvent) -> None: if event.button() == Qt.LeftButton: self.__dragStartPosition = event.pos()
def mousePressEvent(self, e: QMouseEvent): if e.button() == Qt.LeftButton: self._isTracking = True self._startPos = QPoint(e.x(), e.y())
def mouseDoubleClickEvent(self, e: QMouseEvent): self._look_to_star(e.x(), e.y()) super().mouseDoubleClickEvent(e)
def mousePressEvent(self, a0: QtGui.QMouseEvent): if a0.button() == QtCore.Qt.RightButton: self.on_M_RightClick(a0.pos()) elif a0.button() == QtCore.Qt.LeftButton: self.on_M_LeftClick(a0.pos())
def mousePressEvent(self, e: QMouseEvent): if e.buttons() == Qt.LeftButton: self._move_mode = True self._mouse_pos = (e.x(), e.y()) self._mouse_gpos = (e.globalX(), e.globalY()) super().mousePressEvent(e)
def mouseReleaseEvent(self, e: QMouseEvent): if e.button() == Qt.LeftButton: self._isTracking = False self._startPos = None self._endPos = None
def mousePressEvent(self, event: QMouseEvent): if isinstance(self.scene(), GridScene): freq = self.scene().get_freq_for_pos( int(self.mapToScene(event.pos()).x())) if freq is not None: self.freq_clicked.emit(freq)
def mouseReleaseEvent(self, a0: QtGui.QMouseEvent): if a0.button() == QtCore.Qt.RightButton: self.on_M_RightRelease(a0.pos()) elif a0.button() == QtCore.Qt.LeftButton: self.on_M_LeftRelease(a0.pos())
def mouseMoveEvent(self, event: QMouseEvent): if self.scene() is None: return cursor = self.cursor().shape() if self.grab_start is not None: move = self.grab_start.x() - event.pos().x() self.horizontalScrollBar().setValue( self.horizontalScrollBar().value() + move) self.grab_start = event.pos() return if self.separation_area_moving: y_sep = self.mapToScene(event.pos()).y() y = self.sceneRect().y() h = self.sceneRect().height() if y < y_sep < y + h: self.scene().draw_sep_area(y_sep) self.sep_area_moving.emit(y_sep) elif self.is_pos_in_separea(self.mapToScene(event.pos())): self.setCursor(Qt.SplitVCursor) elif cursor == Qt.SplitVCursor: self.unsetCursor() if self.selection_area.finished and not self.selection_area.resizing: pos = self.mapToScene(event.pos()) roi_edge = self.selection_area.get_selected_edge( pos, self.view_rect().width()) if roi_edge is None and cursor == Qt.SplitHCursor: self.unsetCursor() return elif roi_edge == 0 or roi_edge == 1: self.setCursor(Qt.SplitHCursor) if event.buttons() == Qt.LeftButton and self.selection_area.resizing: if self.selection_area.selected_edge == 0: start = self.mapToScene(event.pos()) self.set_selection_area(x=start.x()) self.scroll_mouse(start.x()) return if self.selection_area.selected_edge == 1: start = QPoint(self.selection_area.rect().x(), self.selection_area.rect().y()) end = self.mapToScene(event.pos()) self.set_selection_area(w=end.x() - start.x()) self.scroll_mouse(end.x()) return if self.mouse_press_pos is None: return self.mouse_pos = event.pos() if event.buttons( ) == Qt.LeftButton and not self.selection_area.finished: start = self.mapToScene(self.mouse_press_pos) end = self.mapToScene(self.mouse_pos) self.set_selection_area(w=end.x() - start.x()) self.scroll_mouse(end.x())
def mouseDoubleClickEvent(self, a0: QtGui.QMouseEvent): if a0.button() == QtCore.Qt.RightButton: self.on_M_Right_Double_Click() elif a0.button() == QtCore.Qt.LeftButton: self.on_M_Left_Double_Click()
def mouseDoubleClickEvent(self, evt: QtGui.QMouseEvent) -> None: if self.childAt(evt.pos()) == self.thumbnail.widget(): self.doubleClicked.emit(self)
def mouseMove(widget, pos=QPoint(), delay=-1): event = QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.LeftButton, Qt.NoModifier) qapp.sendEvent(widget, event)
def mousePressEvent(self, event: QMouseEvent): if isinstance(self.scene(), GridScene): freq = self.scene().get_freq_for_pos(int(self.mapToScene(event.pos()).x())) if freq is not None: self.freq_clicked.emit(freq)
def mouseReleaseEvent(self, event: QMouseEvent): """ 鼠标松开时发送信号 """ if self.isSendEventToParent: super().mouseReleaseEvent(event) if event.button() == Qt.LeftButton: self.clicked.emit()
def mouseMoveEvent(self, event: QMouseEvent) -> None: # print('mouseMoveEvent: x=%d, y=%d' % (event.x(), event.y())) if not self.rect().contains(event.pos()): self.close()
def shouldSnap(self, evt: QtGui.QMouseEvent) -> bool: return self.snapToGrid() and not evt.modifiers() & Qt.ShiftModifier
def mousePressEvent(self, event: QMouseEvent): if event.button() == Qt.LeftButton: self.close()
def mouseReleaseEvent(self, e: QtGui.QMouseEvent) -> None: if e.button() == QtCore.Qt.LeftButton: self.pressed = False self.update() self.activate() super().mouseReleaseEvent(e)