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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.