[Interest] Gradient Line

Al-Khanji Louai Louai.Al-Khanji at digia.com
Fri Jan 10 09:34:43 CET 2014


Try setting the finalStop constructor argument to QPointF(0.0, opt.rect.height() - 2). From the documentation:

Note: The expected parameter values are in pixels.

Louai Al-Khanji
Consultant
Digia, Qt

http://qt.digia.com<http://qt.digia.com/>
Qt Blog: http://blog.qt.digia.com/


From: interest-bounces+louai.al-khanji=digia.com at qt-project.org [mailto:interest-bounces+louai.al-khanji=digia.com at qt-project.org] On Behalf Of Igor Mironchik
Sent: 10. tammikuuta 2014 11:16
To: Qt Project
Subject: [Interest] Gradient Line

Hi.

Is it possible to draw single line with gradient?

I've tried something like this:

QLinearGradient g( QPointF( 0.0, 0.0 ), QPointF( 0.0, 1.0 ) );

g.setCoordinateMode( QGradient::ObjectBoundingMode );

g.setColorAt( 0.0, QColor( 50, 50, 60 ) );

g.setColorAt( 0.5, QColor( 140, 140, 150 ) );

g.setColorAt( 1.0, QColor( 50, 50, 60 ) );



p->setPen( QPen( QBrush( g ), 1.0 ) );

p->drawLine( 1, 2, 1, opt.rect.height() - 2 );

But this draws line with average color of gradient: QColor( 105, 105, 115 )


--

Best Regards,

Igor Mironchik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140110/14385863/attachment.html>


More information about the Interest mailing list