Hi! I've been stuck with this for hours, I don't know why I'm doing this wrong, can't understand.
What I want to do is to create a method that returns a QImage, and pass this QImage not a the return type, but as a parameter of the method (I know I can do it other ways, but I really would like to learn why this is wrong and how it should be done).
This is more or less what I did:
myMethod(myImage);
QImage myImage;
myMethod(myImage);
To copy to clipboard, switch view to plain text mode
where myMethod is defined as:
bool MyClass::myMethod(QImage& myImage)
{
...
myImage = QImage::fromData(...
);
...
return true;
}
bool MyClass::myMethod(QImage& myImage)
{
...
myImage = QImage::fromData(...);
...
return true;
}
To copy to clipboard, switch view to plain text mode
I thought that implicit sharing used this way should have assigned the new image to my myImage which, being passed by reference, is my original image. Unfortunately this is wrong as I can see. Why?
Thanks!
Bookmarks