Qt DrawLine - change line color dynamically while drawing, without splitting the line

I am drawing a line in an object derived from QWidget. I can set the pen to draw a line in the color of my choice. What I want to be able to do is change the color of the pen when it's current y coordinate is above a specified value.

One option is simply to split the line I want to draw into two separate halves; split where the y coordinate is above the specified value. While there is nothing wrong with this method, I was hoping that there was a simpler method I could use.

What I want to be able to do is basically extend the drawline function. I want to be able to change the drawing algorithm so that, for each pixel it wants to set the color of, it will check which color to use based on a supplied function.

Answers


I would not recommend to overload the basic drawing algorithm. I think it be more easy to use a QGradient when drawing the line?


Need Your Help

HTML reuse and maintenance with Play! framework

scala playframework tiles reusability maintainability

We have been having discussions in our product dev team regarding html maintainability and reuse. To set the context, we started with HTML5/CSS3 front end with plain JS under Play MVC, which in tur...

Creating two tables while selecting the top row from the previously created table

sql-server-2008 insert

I would like to know more about inserting into one table a value right after creating the first one,