View Full Version : multiple color in QPainterPath

20th September 2010, 17:54

I am trying to draw a multi segment line with different color of each part, is there any ways to do this with QPainterPath ?

Coz there will be hundreds of segments, so that would be great if not using hundreds of path.


20th September 2010, 18:42
QPainterPath only stores shapes, not their properties such as colours.

20th September 2010, 21:21
QGradient and its subclasses might be of interest to you

21st September 2010, 09:10
thanks, i know QPainterPath doesnt maintain any information regarding color.
however, I want drawing a multi-color line into QGraphicsScene for better rotate/zoom in-out handling.

is there any similar approaches ?

21st September 2010, 09:37
QPainterPath itself has nothing to do with "drawing". If you want to draw something, take a look at QPainter class. There is a QPainter::drawLine() method that is meant to draw lines. You can loop over your set of lines, change pen colours and draw lines.