QPainterPath is a class from the Qt Toolkit which provides a container for painting operations, enabling graphical shapes to be constructed and reused.
Questions tagged [qpainterpath]
53 questions
9
votes
1 answer
How can I color QPainterPath subpaths differently?
As the title suggests, I'm looking for a way to color the subpaths of a QPainterPath different colors which is applied to a QGraphicsPathItem, OR simply change the color along the PathItem with a QGradient QPen.
Ultimately I am trying to find the…

bauervision
- 847
- 2
- 9
- 25
4
votes
1 answer
Get Clicked Point Along QPainterPath
How can I get the percentage representing the point clicked along a QPainterPath. For example say I have a line, like the image below, and a user clicks on the QPainterPath, represented by the red dot. I would like to log what percentage the point…

JokerMartini
- 5,674
- 9
- 83
- 193
4
votes
3 answers
How to draw a smooth curved line that goes through several points in QT?
Is there a way to draw a smooth line through a set of points in QT?
The number and position of the points is set during run time.
Currently, I draw a QPainterPath which contains lineTo's going from point to point, creating a path. I do use…

Damir Porobic
- 681
- 1
- 8
- 21
4
votes
2 answers
Shortest distance between a QPainterPath and a QPoint
I have a QPainterPath that can hold any sequence of lines and/or cubic bezier curves. Now, I've got a QPoint that I need to calculate the shortest distance between the QPainterPath and the point. Since the path itself does not do much more than…

msrd0
- 7,816
- 9
- 47
- 82
3
votes
1 answer
PyQt how to convert a QPainterPath to a QPixmap?
I've been searching online and couldn't find a good way to do this. I need to convert a QPainterPath to a QPixmap. Is this possible? If yes, how would this be done? Thanks!

CSforStructuralEngineer
- 523
- 1
- 7
- 14
3
votes
1 answer
Draw only the portion of the QPainter Path bezier curve
I want to draw only the portion of the QPainter Curved Path. I have the path as this:
QPointF p[4];
p[0] = QPoint(100, 200);
p[1] = QPoint(200, 60);
p[2] = QPoint(500, 180);
p[3] = QPoint(600, 100);
cPath.cubicTo(p[1], -a*p[0] + p[1] + a*p[2],…

Gurjot Bhatti
- 977
- 1
- 10
- 24
3
votes
2 answers
How to use QPainterPath?
I'm using pyqt to try to create an application which display images and curves.
To draw bezier curves, I found the QPainterPath class and specifically QpainterPath.cubicTo.
However, I don't understand how this class must be used. In which widget…

arthropode
- 1,361
- 2
- 12
- 19
2
votes
1 answer
QPainter - Draw Polygon with multiple holes
I am trying to draw a polygon with multiple holes in them with QPainter (QT5.8, win64). I am using the following code:
QPainter pm(&image);
QPen p(Qt::gray, 2);
p.setCosmetic(true);
pm.setPen(p);
pm.setBrush(QBrush(color));
QPainterPath…

Richy
- 534
- 4
- 13
2
votes
1 answer
Change QPropertyAnimation duration on the fly
I'm using this solution to animate ellipses along a QPainterPath.
But I need to slowly increase or decrease the speed of the animation.
I create a timer and set a new duration for the animation but the result is a choppy animation because the…

user2246120
- 1,453
- 2
- 17
- 38
2
votes
2 answers
How to crop an image using QPainterPath without saving rest of image
I have a QPainterPath and I want to crop an image which is QPixmap.
This code worked for me but I want to use PyQt5 builtin functionality
like mask without numpy
# read image as RGB and add alpha (transparency)
im =…
user10634893
2
votes
1 answer
QPainterPath drawing and placering items along multiple paths
I have from previous codelines developed and added some special behaviour. The idea is to draw small circle shapes on a certain path inside rectangular shape and circular shape and place them according to the distance given in advance.
I want to…

Pavel.D
- 561
- 1
- 15
- 41
2
votes
1 answer
How do I draw special Circle in Qt5?
I want to draw a special segmented circle like the below image.
But I cannot understand how to draw an arc or ellipse using the
setDashPattern.
Image:
At first, I thought that just drawing a colored circle and drawing a transparent rect or line…

Dev. HenryHoy
- 31
- 3
2
votes
1 answer
Create closed path with moveable nodes in QGraphicScene
I'm trying to extend the great implementation from this answer so the path will be created from the user's clicks inside the graphic-scene and close the path using a double-click.
This works well, but the only issue I couldn't solve yet is the…

avielbl
- 193
- 1
- 7
2
votes
1 answer
qt draw an arc between two points using angle in radians
I want to draw an arc between two points. I know position of the two points and the angle in radians.
I succeeded to wrote a little program to calculate the centre of the circle before to effective draw the arc. But when I draw a circle to verify,…

Junior
- 507
- 5
- 19
1
vote
1 answer
PyQt - How to use arcs to achieve a specfic shape outline
I have a shape drawn with QPainter, which I need to be able to update dynamically, from a single variable called 'width'. I have attached an image to hopefully show what I mean...
Basically the shape should have three parts. Taking the existing…

user2407089
- 59
- 7