[Qt-interest] how to get color from QGraphicsRectItem which is filled with QLinearGradient

Colin Kern colin.kern at gmail.com
Fri May 7 19:59:36 CEST 2010


On Fri, May 7, 2010 at 10:43 AM, franki <franki at franki.eu.org> wrote:
> Question is: how to get color from specific point in this rectangle filled
> with gradient?

The best thing to do might be to just calculate the color yourself.
It's a linear interpolation and you know all the information you'd
need to do this.  You could peek into the Qt source code even and just
find where they calculate the color.  I just spent a few minutes
looking for this, but it didn't jump out at me.  I think it's going to
be somewhere in qbrush.cpp.

I think it might be useful to have a function in QGradient that takes
a QPoint and returns the QColor for that point.  It seems like this
would have to be done internally already to do the painting, so it
shouldn't take too much to expose it in the API.

Colin



More information about the Qt-interest-old mailing list