我们从Python开源项目中,提取了以下29个代码示例,用于说明如何使用PyQt5.QtCore.Qt.RightButton()。
def mousePressEvent(self, ev): ctrl, shift = self._GetCtrlShift(ev) repeat = 0 if ev.type() == QEvent.MouseButtonDblClick: repeat = 1 self._Iren.SetEventInformationFlipY(ev.x(), ev.y(), ctrl, shift, chr(0), repeat, None) self._ActiveButton = ev.button() if self._ActiveButton == Qt.LeftButton: self._Iren.LeftButtonPressEvent() elif self._ActiveButton == Qt.RightButton: self._Iren.RightButtonPressEvent() elif self._ActiveButton == Qt.MidButton: self._Iren.MiddleButtonPressEvent()
def mouseMoveEvent(self, event): dx = event.pos().x() - self._lastPos.x() dy = event.pos().y() - self._lastPos.y() if self.isRotating: if event.buttons() == Qt.LeftButton: self.setXRotation(self.rotX - dy / 2) self.setYRotation(self.rotY + dx / 2) elif event.buttons() == Qt.RightButton: self.setXRotation(self.rotX - dy / 2) self.setZRotation(self.rotZ + dx / 2) elif self.isPanning: if event.buttons() == Qt.LeftButton: min_side = min(self.frameSize().width(), self.frameSize().height()) dx, dy, dz = self.deRotate(dx, dy, 0) self.posX += dx / min_side self.posY += dy / min_side self.posZ += dz / min_side self._lastPos = event.pos() self.update()
def mouseMoveEvent(self,event): if self.timer!=None: self.timer.stop() self.timer=None if self.lastPos==None: self.lastPos=event.pos() dx = event.x() - self.lastPos.x(); dy = event.y() - self.lastPos.y(); if event.buttons()==Qt.LeftButton: self.viewpoint.xRot =self.viewpoint.xRot + 1 * dy self.viewpoint.yRot =self.viewpoint.yRot + 1 * dx if event.buttons()==Qt.RightButton: self.viewpoint.x_pos =self.viewpoint.x_pos + 0.1 * dx self.viewpoint.y_pos =self.viewpoint.y_pos - 0.1 * dy self.lastPos=event.pos() self.setFocusPolicy(Qt.StrongFocus) self.setFocus() self.update()
def clicking_close_to_a_link_will_select_it_on_the_plot(self): pdds, nwm = draw_a_network(self.aw, network=ex.networks[0]) # select a link l = pdds.links[3] pos = [(l.start.x + l.end.x) / 2.0, (l.start.y, l.end.y) / 2.0] curve = [x for x in nwm.get_plot().get_items() if x.title().text() == l.id][0] plot = curve.plot() ax = curve.xAxis() ay = curve.yAxis() px = plot.transform(ax, pos[0]) py = plot.transform(ay, pos[1]) logger = logging.getLogger() logger.info(curve.title().text()) QTest.mouseClick(plot, Qt.RightButton, pos=QPoint(px, py), delay=10.) logger = logging.getLogger() logger.info(str(plot.get_selected_items())) logger = logging.getLogger() logger.info((nwm.get_plot().get_selected_items())) # this test does not work yet. # todo: fix this test to work.
def mouseMoveEvent(self, e): if e.buttons() != Qt.RightButton: return mimeData = QMimeData() drag = QDrag(self) drag.setMimeData(mimeData) drag.setHotSpot(e.pos() - self.rect().topLeft()) dropAction = drag.exec_(Qt.MoveAction)
def mouseMoveEvent(self, event): dx = event.x() - self.lastPos.x() dy = event.y() - self.lastPos.y() if event.buttons() & Qt.LeftButton: self.setXRotation(self.xRot + 8 * dy) self.setYRotation(self.yRot + 8 * dx) elif event.buttons() & Qt.RightButton: self.setXRotation(self.xRot + 8 * dy) self.setZRotation(self.zRot + 8 * dx) self.lastPos = event.pos()
def mouseReleaseEvent(self, ev): ctrl, shift = self._GetCtrlShift(ev) self._Iren.SetEventInformationFlipY(ev.x(), ev.y(), ctrl, shift, chr(0), 0, None) if self._ActiveButton == Qt.LeftButton: self._Iren.LeftButtonReleaseEvent() elif self._ActiveButton == Qt.RightButton: self._Iren.RightButtonReleaseEvent() elif self._ActiveButton == Qt.MidButton: self._Iren.MiddleButtonReleaseEvent()
def mousePressEvent(self, event): if event.button() == Qt.LeftButton: if self.iodir == "output": self.newbezier = Node.io.BezierCurve(self, None) elif self.iodir == "input": self.newbezier = Node.io.BezierCurve(None, self) if self.newbezier is not None: self.newbezier.update(QPointF(event.pos() + self.pos() + self.parent.pos())) self.parent.parent.scene.addItem(self.newbezier) elif event.button() == Qt.RightButton: self.delAllBezier()
def mouseReleaseEvent(self, event): if event.button() == Qt.LeftButton or event.button() == Qt.RightButton: if self.isPanning: self.setCursor(Qt.OpenHandCursor) elif self.isRotating: self.setCursor(Qt.PointingHandCursor)
def mousePressEvent(self, event): if event.button() in (Qt.LeftButton, Qt.RightButton): self._oldSelection = set(self._selection) index = self._findIndexForEvent(event) modifiers = event.modifiers() if index is None: if not (modifiers & Qt.ControlModifier or modifiers & Qt.ShiftModifier): # TODO: consider setSelection(None) self.setSelection(set()) return if modifiers & Qt.ControlModifier: if index in self._selection: self._selection.remove(index) else: self._selection.add(index) elif modifiers & Qt.ShiftModifier: self._selection = self._linearSelection(index) elif index not in self._selection: self._selection = {index} else: self._maybeDragPosition = event.localPos() self._lastSelectedCell = index self.selectionChanged.emit() self.update() else: super(GlyphCellWidget, self).mousePressEvent(event)
def mouseMoveEvent(self, event): if event.buttons() & (Qt.LeftButton | Qt.RightButton): index = self._findIndexForEvent(event, True) if index == self._lastSelectedCell: return if self.maybeExecuteDrag(event): return self.scrollToCell(index) if index >= len(self._glyphs): return modifiers = event.modifiers() if modifiers & Qt.ControlModifier: if index in self._selection and index in self._oldSelection: self._selection.remove(index) elif index not in self._selection and \ index not in self._oldSelection: self._selection.add(index) elif modifiers & Qt.ShiftModifier: self._selection = self._linearSelection(index) else: self._selection = {index} self._lastSelectedCell = index self.selectionChanged.emit() self.update() else: super(GlyphCellWidget, self).mouseMoveEvent(event)
def mouseReleaseEvent(self, event): if event.button() in (Qt.LeftButton, Qt.RightButton): self._maybeDragPosition = None # XXX: we should use modifiers registered on click if not event.modifiers() & Qt.ShiftModifier: if self._lastSelectedCell is not None: self._selection = {self._lastSelectedCell} else: self._selection = set() self.update() self._oldSelection = None else: super(GlyphCellWidget, self).mouseReleaseEvent(event)
def mouseDoubleClickEvent(self, event): if event.button() in (Qt.LeftButton, Qt.RightButton): index = self._findIndexForEvent(event) if index is not None: self.glyphActivated.emit(self._glyphs[index]) else: super(GlyphCellWidget, self).mouseDoubleClickEvent(event)
def mouseMoveEvent(self, event): dx = event.x() - self.lastPos.x() dy = event.y() - self.lastPos.y() if event.buttons() & Qt.LeftButton: self.rotateBy(8 * dy, 8 * dx, 0) elif event.buttons() & Qt.RightButton: self.rotateBy(8 * dy, 0, 8 * dx) self.lastPos = event.pos()
def mouseMoveEvent(self, event): dx = event.x() - self.lastPos.x() dy = event.y() - self.lastPos.y() if event.buttons() & Qt.LeftButton: self.setXRotation(self.xRot + 8 * dy) self.setYRotation(self.yRot + 8 * dx) elif event.buttons() & Qt.RightButton: self.setXRotation(self.xRot + 8 * dy) self.setZRotation(self.zRot + 8 * dx) self.lastPos = QPoint(event.pos())
def on_mb_click(self, button, addr, mouse_offs): if button == Qt.MiddleButton: self._set_xor_key() elif button == Qt.RightButton: key = get_byte(addr + mouse_offs) self._set_xor_key(key)
def on_mb_click(self, button, addr, mouse_offs): if button == Qt.RightButton: self._set_user_expr()
def on_mb_click(self, button, addr, mouse_offs): if button == Qt.MiddleButton: pass elif button == Qt.RightButton: self.switch ^= 1 print "Highlighting %s" % self.mode[self.switch]
def mousePressEvent(self, event): super(HomographyScene, self).mousePressEvent(event) loc = (event.scenePos().x(), event.scenePos().y()) clicked_point, cp_index = self.find_clicked_point(loc) if clicked_point: if event.button() == Qt.RightButton: # Right click to delete points self.delete_point(clicked_point, cp_index) else: # Note that we are currently moving a point self.point_selected = True self.selected_point = clicked_point self.selected_point.setCursor(self.parent().cursor_drag) else: # Otherwise add a new point if self.main_pixmap_item.isUnderMouse(): # Check to make sure we're in the image. self.add_point(loc)