2

is QImage based on QSharedData ? Do Qimage follow pimpl or copy on write ? e.g. would copying(through copy con or assignment) an Qimage make a deep copy of pixels ?

demonplus
  • 5,613
  • 12
  • 49
  • 68
Neel Basu
  • 12,638
  • 12
  • 82
  • 146

1 Answers1

3

QImage is copy on write. It will not copy pixels until you start modifying it.

For what it's worth when passing it into functions, I always use const QImage & anyway not to freak anyone out.

MrFox
  • 1,244
  • 1
  • 11
  • 24
  • 2
    A reference to documentation that proves your statement would be highly desirable. – liori Sep 03 '14 at 23:58
  • Late to the party, but [here](https://doc.qt.io/qt-5/qimage.html#details) you can read that `QImage` uses implicit data sharing. – Adversus Mar 12 '21 at 14:24