我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PyQt5.QtCore.Qt.RoundJoin()。
def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.scale(self.width() / 100.0, self.height() / 100.0) painter.translate(50.0, 50.0) painter.rotate(-self.rotationAngle) painter.translate(-50.0, -50.0) painter.setPen( QPen(self.penColor, self.penWidth, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) gradient = QLinearGradient(0, 0, 0, 100) gradient.setColorAt(0.0, self.fillColor1) gradient.setColorAt(1.0, self.fillColor2) painter.setBrush(QBrush(gradient)) painter.drawPath(self.path)
def paint(self, painter, option, widget): if not self.source or not self.dest: return # Draw the line itself. line = QLineF(self.sourcePoint, self.destPoint) if line.length() == 0.0: return painter.setPen(QPen(Qt.black, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) painter.drawLine(line) # Draw the arrows if there's enough room. angle = math.acos(line.dx() / line.length()) if line.dy() >= 0: angle = VGraphEdge.TwoPi - angle sourceArrowP1 = self.sourcePoint + QPointF(math.sin(angle + VGraphEdge.Pi / 3) * self.arrowSize, math.cos(angle + VGraphEdge.Pi / 3) * self.arrowSize) sourceArrowP2 = self.sourcePoint + QPointF(math.sin(angle + VGraphEdge.Pi - VGraphEdge.Pi / 3) * self.arrowSize, math.cos(angle + VGraphEdge.Pi - VGraphEdge.Pi / 3) * self.arrowSize); destArrowP1 = self.destPoint + QPointF(math.sin(angle - VGraphEdge.Pi / 3) * self.arrowSize, math.cos(angle - VGraphEdge.Pi / 3) * self.arrowSize) destArrowP2 = self.destPoint + QPointF(math.sin(angle - VGraphEdge.Pi + VGraphEdge.Pi / 3) * self.arrowSize, math.cos(angle - VGraphEdge.Pi + VGraphEdge.Pi / 3) * self.arrowSize) painter.setBrush(Qt.black) painter.drawPolygon(QPolygonF([line.p1(), sourceArrowP1, sourceArrowP2])) painter.drawPolygon(QPolygonF([line.p2(), destArrowP1, destArrowP2]))
def init_ui(self): self.pen = QPen() self.pen.setWidth(self.width) self.pen.setJoinStyle(Qt.RoundJoin) self.pen.setCapStyle(Qt.RoundCap) self.setPen(self.pen) self.setFlag(QGraphicsItem.ItemIsMovable) self.setFlag(QGraphicsItem.ItemIsSelectable)
def drawLineTo(self, endPoint): painter = QPainter(self.image) painter.setPen(QPen(self.myPenColor, self.myPenWidth, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) painter.drawLine(self.lastPoint, endPoint) self.modified = True rad = self.myPenWidth / 2 + 2 self.update(QRect(self.lastPoint, endPoint).normalized().adjusted(-rad, -rad, +rad, +rad)) self.lastPoint = QPoint(endPoint)