How to perform a deep copy on a QImage?
What I have is like this:
texture_img = camWorker->getImage();
QImage CamWorker::getImage(){
QMutexLocker locker(&mutex);
return QImg;
}
and the QImg is from a stream Video.
However I found that the texture_img = camWorker->getImage();
only performs a shallow copy over QImage, and when the QImg is changed in another thread it creates seg-fault.
Will a deepcopy solve the problem?
As Amartel has pointed out, QImage
provides a copy
method.
QImage image_copy = image.copy();
See here for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With