jijiz | Bonjour, Je souhaite afficher uniquement la cubique et non le trait qui part de la fin du tracé et qui revient au début :
Voici le code :
Code :
- class CubicDragable(QtGui.QLabel):
- def __init__(self, QP1, QP2, parent=None):
- super (CubicDragable, self).__init__ (parent)
- # Construct the path
- path = QtGui.QPainterPath()
- path.setFillRule(QtCore.Qt.OddEvenFill)
-
- # Drawing the cubic to gap 2 points
- if (QP1.x()<QP2.x()):
- # Coordinates of the first control point
- QPc1 = QtCore.QPointF((QP2.x()-QP1.x())/2,QP1.y())
- # Coodinates of the second control point
- QPc2 = QtCore.QPointF((QP2.x()-QP1.x())/2,QP2.y())
- else:
- # Coordinates of the first control point
- QPc1 = QtCore.QPointF((QP1.x()-QP2.x())/2,QP1.y())
- # Coodinates of the second control point
- QPc2 = QtCore.QPointF((QP1.x()-QP2.x())/2,QP2.y())
- path.moveTo(QP1)
- path.cubicTo(QPc1,QPc2,QP2)
- path.closeSubpath()
-
- # Area where the path will be drawn
- image = QtGui.QImage(abs(QP1.x()- QP2.x()), abs(QP1.y()- QP2.y()),
- QtGui.QImage.Format_ARGB32_Premultiplied)
-
- # Start the painting device
- painter = QtGui.QPainter()
- painter.begin(image)
- painter.setRenderHint(QtGui.QPainter.Antialiasing)
- # Dawing the path of our cubic
- painter.drawPath(path)
- self.setPixmap(QtGui.QPixmap.fromImage(image))
- painter.end()
|
Merci |