PDA

View Full Version : QImage declaration and intitialization?



shawnlau
28th June 2018, 22:42
If I declare a pointer to a QImage I can do this:



QImage *myImage;

//and later..

myImage = new QImage(800,800,QImage::Format_ARGB32)


And if I declare a QImage with the default constructor, it will give me a null QImage and I can do this:


QImage myImage;
//and later
myImage.load(file);


Is there any way to declare a QImage and later set it up as 800,800,QImage::Format_ARGB32 ?

shawnlau
29th June 2018, 01:23
This seems to work but it seems conflated:


QImage myImage;
QImage *temp = new QImage(800,800,QImage::Format_ARGB32);
myImage = *temp;


There is no QImage function to do this? Also, lets say myImage was not a null QImage, but an actual image in a class . Assigning a new image to it, does that create a memory leak or does QImage take care of that? I come from Java and the system takes care of all orphaned objects.