PDA

View Full Version : Convert to painter



wirasto
21st January 2010, 20:57
I tied convert this stylesheet to painter, but I'm failed.

stylesheet


"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);"


painter


QLinearGradient linearGrad(0, 0, 0, 1);
linearGrad.setColorAt(0, QColor("#e7effd"));
linearGrad.setColorAt(1, QColor("#cbdaf1"));

painter->fillRect(option.rect, QBrush(linearGrad));


What is wrong ?

wysota
22nd January 2010, 00:41
linearGrad(0,0,0,1) will make you a gradient that is 0 pixels wide and 1 pixel high. That's probably not what you want. Either set a different Spread for the gradient or use absolute (as opposed to relative used by style sheets) coordinates.