That’s probably a trick question, but I’m not sure;
Do I have to call delete after :
QImage::copy()QImage::load(QString)QPixmap::fromImage(QImage)
By delete I mean, deleting it when I don’t need it any more.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
QImage objects are not special in how they are created and destroyed. On the stack or with new/delete or whatever, the rules are the same as for all C++ objects.
QImage is implicitly shared, so copying it is cheap (like a shared pointer) but it performs copy-on-write to preserve value semantics.
Short story, you probably don’t ever have to new/delete a QImage, just pass it around as a value and quit worrying.
You don’t have to do any special deleting after calling copy/load methods, although you might want to assign
my_image=QImage()to release cached data or something.