[Solved]Using qpainter to create image

I am trying to create a css generator like the one here: "http://www.colorzilla.com/gradient-editor/":http://www.colorzilla.com/gradient-editor/ . The preview pane dynamically changes according to the options selected. I want to create something of that sort. I'm trying to use QPainter to draw QRects, but unable to apply gradients. And how to apply border radius to it? And finally, I should be able to convert the preview to an image. Please help me out.
Thanks in advance!