PDA

View Full Version : qcolor reverse lighter



mcarter
17th June 2011, 16:28
I have a QGraphicsRectitem that I want to highlight by changing the color of the pen when you enter the item and change it back when you leave. The rect can have various colors. I am trying to use the setPen(pen().color().lighter(150)) in the enter event and setPen(pen().color.darker(200)) in the leave event, but the darker does not reproduce the original color and eventually the rect becomes black after entering/leaving enough times. Is there a way to truly reverse the effects of the lighter function? Is it best to just use two internal color variables?

stampede
17th June 2011, 16:36
Why two ? Just original (when item is not "entered") pen color will be enough:

setPen(this->_color.lighter(150));// in the enter event
setPen(this->_color); //in the leave event

mcarter
20th June 2011, 18:19
Oh, that is true . . . good idea . . . thanks