[Solved] Translation from stylesheet gradient to gradient class
-
wrote on 19 Jul 2013, 16:57 last edited by
Hi all,
I used to have a rectangle having its background painted with a qlineargradient in a stylesheet, but I had to move the painting to an item delegate. However, trying to translate the stylesheet syntax into a QLinearGradient instance don't work properly for me; I simply see no gradient, only evenly distributed background color.
The stylesheet gradient definition: qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:0.057727, stop:0 #7B99BB, stop:1 #9CB6D5 )
My attempt to translate into QLinearGradient:
@QLinearGradient gradient(1.0, 1.0, 1.0, 0.057727);
gradient.setSpread(QLinearGradient::PadSpread);
gradient.setColorAt(0, QColor("#7B99BB"));
gradient.setColorAt(1, QColor("#9CB6D5"));@(And of course the painting of the rect hereafter).
Can anybody point me in a direction that actually might work?
-
wrote on 20 Jul 2013, 08:11 last edited by
Seems like the gradient needs to have
@gradient.setCoordinateMode(QLinearGradient::ObjectBoundingMode);@
when constructed with start and stop points instead of coordinates.
How obvious! [/sarcasm]
1/2