PDA

View Full Version : Drawing a line with a linear gradient effect



toutarrive
14th February 2010, 19:06
Hello,

I need for an app to be able to draw simple lines with gradient effect.

After doing some research , i've found in Qt Labs Blog that is possible to set the palette brush on either a painter pen (or a painter brush) using this kind of code :


// Use the QPalette::Button role’s brush entry as a pen
painter->setPen(QPen(palette.button(), 0));
painter->drawLine(rect.topLeft(), rect.topRight());


What i don't get is how to set the QPalette::Button role’s brush to a gradient.

In Qt Assistant , they say that QPalette::BrightText role can be used as well to draw lines. What are the differences ?

Regards.

Olivier

Lykurg
14th February 2010, 20:35
Salut,

as far as I know you don't have a possibility to get the gradient of a push button. This is because the gradient is composed direct in the styles "paint event" using the defined colours with modifications (QColor::darker() and lighter). So you have to compose your own gradient. Or have a look at the sources of a style how they draw the gradient and take that code to your drawing.

Lykurg

toutarrive
14th February 2010, 23:39
Merci.

I'll have a look at the sources.
I wil, as well,l investigate further on this QPalette::BrightText role.
I do believe KDE as implemented this kind of gradient line. Maybe someone has got some tech specs on that matter.
In case of any progress in this matter, i'll get back to you to you Lukurg.

Auf Wiedersehen.

toutarrive
14th February 2010, 23:42
Lykurg , I mean.

toutarrive
15th February 2010, 08:42
here is the link to the article

http://labs.trolltech.com/blogs/2005/11/15/pens-brushes-colors-and-brushes