View Full Version : QGradient on triangle

20th June 2012, 18:57
I need fill instances of QGraphicsPolygonItem (really they are triangles of finite element mesh) using QGragient. I'd like to show stress field in the way. I have stresses in each vertex of mesh that is in each vertex of a triangle. Need I use LinearGradient or RadialGradient? Please help me with triangle gradient or give me a useful referance. Thank you.

20th June 2012, 19:34
You need to use three linear gradients.

20th June 2012, 20:11
I can create three linear gradients along each segment of triangle. Then I will create three brushes using these gradients. But how can I unite three fillings. Need I reimplement QGraphicsItem::paint()? Thank you very much.

20th June 2012, 20:34
Either clip to the shape of triangle and draw a rectangle over it or draw a polygon.