PDA

View Full Version : QLinearGradient Coloring



WSQtProgrammer
5th July 2012, 16:59
Greetings,

I am wondering if it is possible to use a QGradient and assign it a custom color range.

Let me explain : I am building an histogram with Qwt, and I wish to have the columns of that histogram to follow a specific set of colors.

Example: When the user selects a cold color range, the histogram is displayed using the following method : The leftmost column starts in black and goes slowly towards blue, the middle column goes from blue to pink and the rightmost column goes from pink to white.

My question is, if I use QLinearGradient and give it stops increments of 0.25 with black, blue, pink, white as the stop colors, can I make it follow the colors I give it or is it always going to use the chromatic circle's gradient to put between the stops?

Thank you,

d_stranz
5th July 2012, 17:59
It is going to use whatever the internal implementation is (maybe that's the chromatic circle, I don't know) to interpolate between stops. If you want some other interpolation scheme, you need to either write your own QGradient class. And since it looks like QGradient has no public methods for retrieving the color for a specific location, QBrush must have privileged access to QGradient (friend status) so you'll have to look into the QBrush and QGradient source code to find out in detail how to implement your own gradient class.