Hi everybody, i want to know how can i copy all content of a QPainter object to a QImage?
i dont have orginal widget reference. before programmers only send QPainter object to another functions.
thanks.
Hi everybody, i want to know how can i copy all content of a QPainter object to a QImage?
i dont have orginal widget reference. before programmers only send QPainter object to another functions.
thanks.
QPainter doesn't have any "content". If you want to copy content of one paint device to another paint device, the source paint device has to allow it by providing a way to render itself using QPainter (e.g. QWidget::render()).
danics (14th January 2013)
in qt3 we have bilBlt function for copy one PaintDevice to another, so if i dont know main type of paintdevice how can i copy its content in qt4, however, you mean if i know the main type i can cast it like this?
destpainter.drawImage(0,0, (QImage) (*((QImage*)sourcepainter->device()));
and if i havent paint device type i must using qt3support or another option?
Last edited by danics; 14th January 2013 at 10:00.
i have a old program with 170000 lines of code, i must change something in that and port it to qt 4.8, so they have so many function and only send the qpainter object to these functions , i must get a copy of all content of this painters to some images. i haven't the main widget or image reference, now how can i do this?
It still doesn't explain what you are trying to do. Architecture of Qt3 and Qt4 drawing differs greatly, there is no single magic call you can use.
Ok, I know content of painter's, they have some symbols and i need to extract them, i know the coordinates of symbols and i know the background color too i must extract this symbol without background and load them in another widgets,
it seems i must use bitBlt there is no other choice, am i right?
you want me to casting paintingdevice?
i m sure its not qwidget its qimage or qpixmap or qbitmap i dont know exactly what is that!
I'm asking you to look into the source code of the application you are maintaining and see what is the source device for the call being made.
So check. If it's QImage or QPixmap (or QBitmap which is its subclass) then you can use QImage::copy() or QPixmap::copy().i m sure its not qwidget its qimage or qpixmap or qbitmap i dont know exactly what is that!
if i wanna do this i must check so much code, and change so many functions for referencing that object too, if i have only QPainterDevice i cannot do anything?
Bookmarks