PDA

View Full Version : implicit or shared copy?



SkripT
17th February 2006, 13:23
hi all, I would like to know if the result of the operation:

QImage im2 = im1.scaledToWidth(245);
Generates a deep copy or a shallow copy? The operator= of Qimages generates shallow copies but i'm not sure in the case of the operation above. Thanxs.

Codepoet
17th February 2006, 13:51
scaledToWidth creates a copy of your image.

SkripT
17th February 2006, 14:10
scaledToWidth creates a copy of your image.

Yes I know, the question is if this copy is a deep copy or a shallow copy?

Codepoet
17th February 2006, 14:16
It has to be a deep copy because the underlying data was newly created:


QImage temp = im.scaledToWidth(...);// deep copy
scaledImage = temp;// shallow copy

SkripT
17th February 2006, 15:14
That's exactly what I expected