You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Thursday, November 2nd 2017, 2:48pm

Multiple Colors on a QGraphicsPathItem?

I would like to know if there is a way to have a single QGraphicsPathItem change colors as it gets drawn? In the image below you can see what I'm trying to figure out. I need to have my line be able to switch between 3 colors, and have those colors "stored" along the path.

For example, imagine that this line is being drawn over time. It starts out red, soon a variable gets set and the color of the line segments being drawn change to orange. The red portions of the line remain intact so we can see historically what the state of the variable was at that time. At different times, the variable adjusts and the color applied to new portions of the line update accordingly.

When the line has finished drawing, we can look at it and see when the colors changed.

It would be wonderful if this could all be a single PathItem, but I don't think that is possible.

Similar threads