Hi,
I am developing an application, which requires to plot .png image on the screen. A maximum of 20 images can be placed and also, while scrolling left or right, images should also move. To handle this, i have to paint images in paintevent() function. Calling painevent so frequently, increases the umemory, The image size is 1KB, but with 20 pins on screen, and left scroll, images increase by about 0.5mb everytime.
I have used this approach to put images on the screen:
QPixmapCache::clear();
m_BluePin = new QPixmap(":/images/pin-blue.png");
p.drawPixmap(pt, *m_BluePin);
delete m_BluePin;
and 2nd approach:
QPixmap blue_pixmap;
if (!QPixmapCache::find(":/images/pin-blue.png", blue_pixmap)) {
blue_pixmap = QPixmap(":/images/pin-blue.png");
QPixmapCache::insert(":/images/pin-blue.png", blue_pixmap);
}
p.drawPixmap(blue_pt, blue_pixmap);
Both seems to take same amount of space. Also, at later part of the application, I remove pins one after another, but this does not reduce the heap memory used. Instead it increases the memory.
Is there a way, to clear the previous data of paintevent() before calling painteventevent() again?
Thanks in advance.



