PDA

View Full Version : how to save somtihing drawed on QPaiter to an image?



cxl2253
12th December 2006, 09:03
I draw something like line, arc ,eclipse etc on QPaiter ,NOw I want to save them in an image.But how to do it? can anybody help me ?

munna
12th December 2006, 09:17
You will need to specify the paint device for the QPainter

Something like




QPixmap pm(width,height);
QPainter painter(&pm);
....
....
//Your drawing code
....
pm.save(filename,format);

cxl2253
15th December 2006, 09:11
thanks for reply soon. YES, what you said can pait them to an image .but there comes another problem, which will not show on paiter widget . I Want to show them on a widget, but at the same ,i can save to an image file.

why QPAINTER not provide the save function ? just like delphi TCANVAS ?

jpn
15th December 2006, 09:34
QPainter can paint on a single QPaintDevice at time. You can use QPainter::setRedirected() to redirect the painting to another device. But maybe QPixmap::grabWidget() is more like what you're after?