我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用PySide.QtCore.QPoint()。
def setPositionClicked(self,x,y): x = round(x) y = round(y) if self.transformationPointState == TransfomationPointState.TopLeft: self.btn_find_top_left.setText("pos: "+str(x)+"/"+str(y)) self.transform_target_topleft.setX(x) self.transform_target_topleft.setY(y) self.transform_target_topleft_set = True elif self.transformationPointState == TransfomationPointState.BottomRight: self.btn_find_bot_right.setText("pos: "+str(x)+"/"+str(y)) self.transform_target_bottom_right.setX(x) self.transform_target_bottom_right.setY(y) self.transform_target_bottom_right_set = True self.calc_transform(0) if self.transformationPointState == TransfomationPointState.TopLeft: self.area.set_marker(self.transFormMatrix.map(QtCore.QPoint(self.spin_transformation_a_x.value(),self.spin_transformation_a_y.value())),False) elif self.transformationPointState == TransfomationPointState.BottomRight: self.area.set_marker(self.transFormMatrix.map(QtCore.QPoint(self.spin_transformation_b_x.value(),self.spin_transformation_b_y.value())),False) self.transformationPointState = TransfomationPointState.Nope
def getNewPosition(self): '''Return the position of this task widget according to the index of its task''' x = 0 if self.task.index >= 0: # VISIBLE WIDGETS MOVE UP TO FILL SPACE y = self.task.index * TaskWidget.TASKWIDGETHEIGHT * TaskWidget.TASKWIDGETSPACING elif self.task.index == -1: # HIDDEN WIDGETS MOVE UP y = self.task.index * self.height() self.raise_() elif self.task.index == -2: # DELETED WIDGETS DROP DOWN y = self.parentWidget().height() self.raise_() return QtCore.QPoint(x, y)
def paintEvent(self, event): painter = QtGui.QPainter(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) pen = painter.pen() if self.active or self.hasFocus(): pen.setColor(self.activeColor) else: pen.setColor(self.inactiveColor) pen.setWidth(3) pen.setCapStyle(QtCore.Qt.PenCapStyle.RoundCap) painter.setPen(pen) polygon1 = QtGui.QPolygon() polygon1 << QtCore.QPoint(self.padding, self.padding) << QtCore.QPoint(self.width() - self.padding, self.height() - self.padding) polygon2 = QtGui.QPolygon() polygon2 << QtCore.QPoint(self.padding,self.height() - self.padding) << QtCore.QPoint(self.width() - self.padding, self.padding) polygon1.translate(0,1) polygon2.translate(0,1) painter.drawPolyline(polygon1) painter.drawPolyline(polygon2)
def paint(self, painter, option, index): painter.fillRect(option.rect, index.data(QtCore.Qt.BackgroundRole)) super(NewWindowCorrelationTableDisplay.BackgroundDelegate, self).paint(painter, option, index) if option.state & QtGui.QStyle.State_Selected: painter.save() # Changed to Green pen = QtGui.QPen(QtCore.Qt.darkGreen, 2, QtCore.Qt.SolidLine, QtCore.Qt.SquareCap, QtCore.Qt.MiterJoin) myrect = option.rect.adjusted(0, 1, 0, 0) painter.setPen(pen) painter.setPen(pen) painter.drawLine(myrect.topLeft(), myrect.topRight()) painter.drawLine(option.rect.bottomRight() , option.rect.bottomLeft()) painter.drawLine(myrect.topLeft(), myrect.bottomLeft()) painter.drawLine(option.rect.topRight() + QtCore.QPoint(0, 2), option.rect.bottomRight()+ QtCore.QPoint(0, -2)) painter.restore()
def paint(self, painter, option, index): painter.fillRect(option.rect, index.data(QtCore.Qt.BackgroundRole)) super(CorrelationTableDisplay.BackgroundDelegate, self).paint(painter, option, index) if option.state & QtGui.QStyle.State_Selected: painter.save() # Pointer to green pen = QtGui.QPen(QtCore.Qt.darkGreen, 2, QtCore.Qt.SolidLine, QtCore.Qt.SquareCap, QtCore.Qt.MiterJoin) myrect = option.rect.adjusted(0, 1, 0, 0) painter.setPen(pen) painter.drawLine(myrect.topLeft(), myrect.topRight()) painter.drawLine(myrect.bottomLeft(), myrect.bottomRight()) if index.column() == 0: painter.drawLine(myrect.topLeft(), myrect.bottomLeft()) if index.column() == index.model().columnCount()-1: painter.drawLine(option.rect.topRight() + QtCore.QPoint(0, -1), option.rect.bottomRight()+ QtCore.QPoint(0, -1)) painter.restore()
def paint(self, painter, option, index): painter.fillRect(option.rect, index.data(QtCore.Qt.BackgroundRole)) super(CommunityCorrelationTableDisplay.BackgroundDelegate, self).paint(painter, option, index) if option.state & QtGui.QStyle.State_Selected: painter.save() # pointer to gree pen = QtGui.QPen(QtCore.Qt.darkGreen, 2, QtCore.Qt.SolidLine, QtCore.Qt.SquareCap, QtCore.Qt.MiterJoin) myrect = option.rect.adjusted(0, 1, 0, 0) painter.setPen(pen) painter.drawLine(myrect.topLeft(), myrect.topRight()) painter.drawLine(myrect.bottomLeft(), myrect.bottomRight()) if index.column() == 0: painter.drawLine(myrect.topLeft(), myrect.bottomLeft()) if index.column() == index.model().columnCount()-1: painter.drawLine(option.rect.topRight() + QtCore.QPoint(0, -1), option.rect.bottomRight()+ QtCore.QPoint(0, -1)) painter.restore()
def make_active(self, world_to_point=False): self.__saved_point = self.current_point.save() if not world_to_point: pt = self.view.viewState.tfW2V(self.current_point.get()) bounds = Rect.fromPoints(Point2(0,0), Point2(self.view.width(), self.view.height())) pt_clipped = clip_point_to_rect(pt, bounds) screen_pt = self.view.mapToGlobal(QtCore.QPoint(*pt_clipped.intTuple())) QtGui.QCursor.setPos(screen_pt) else: rect_pt = Point2(self.view.mapFromGlobal(QtGui.QCursor.pos())) world_pt = self.view.viewState.tfV2W(rect_pt) self.current_point.set(world_pt) self.__point_active = True
def on_fetch_top_left(self,i): self.area.set_marker(self.transFormMatrix.map(QtCore.QPoint(self.spin_transformation_a_x.value(),self.spin_transformation_a_y.value())),False) self.transformationPointState = TransfomationPointState.TopLeft
def on_fetch_bottom_right(self,i): self.area.set_marker(self.transFormMatrix.map(QtCore.QPoint(self.spin_transformation_b_x.value(),self.spin_transformation_b_y.value())),False) self.transformationPointState = TransfomationPointState.BottomRight
def paintEvent(self, event): '''Paint the button grey if not highlighted, else yellow''' painter = QtGui.QPainter(self) colour = QtGui.QColor(247, 147, 30, 150) gradient = QtGui.QLinearGradient(QtCore.QPoint(0,0), QtCore.QPoint(self.width()/2, 0)) gradient.setColorAt(0, QtCore.Qt.transparent) gradient.setColorAt(1, colour) gradient.setSpread(QtGui.QGradient.ReflectSpread) painter.setBrush(QtGui.QBrush(gradient)) painter.setPen(QtCore.Qt.transparent) rect = QtCore.QRect(0,0,self.width(),self.height()) painter.drawRect(rect)
def inputPos(self): x = self.pos().x() y = self.pos().y() - self.size.y()/2 return QtCore.QPoint(x,y)
def outputPos(self): x = self.pos().x() y = self.pos().y() + self.size.y()/2 return QtCore.QPoint(x,y)
def __init__(self, parent, isInput_): super(Connector,self).__init__() self.size=QtCore.QPoint(20,6) self.isInput_ = isInput_ self.parent_ = parent self.setZValue(10000) self.setParentItem(parent) if self.isInput_: self.setPos(QtCore.QPoint(0,-parent.size.y()/2)) else: self.setPos(QtCore.QPoint(0,parent.size.y()/2))
def readSettings(self): ''' Read position and size from QSettings ''' settings = QtCore.QSettings('PH5', 'pforma') pos = settings.value('pos', QtCore.QPoint(200, 200)) size = settings.value('size', QtCore.QSize(400, 400)) self.move(pos) self.resize(size)