In my main class that controls a window, I have this function, where pixmapItem
is a QGraphicsPixmapItem*
defined in the class header:
void updateDisplay() {
uchar *data = new ...; // array of pixel data
...
QImage image = QImage(data, width, height,
width, QImage::Format_Indexed8);
pixmapItem->setPixmap(QPixmap::fromImage(image));
}
My question is: How can I destroy data
when it is not needed anymore? "Not needed anymore" means that the function above or another function in my class sets the pixmap to another image.
I have seen that QImage has cleanup functions that may help, but the documentation is not really clear on how to use them and how to pass parameters such as the data pointer of the image to delete.