qt - How to avoid objects copying during passing from C++ to QML and again to C++? -


i try load qimage c++ qml. created subclass of qquickpainteditem in load qimage(casted qvariant) using slot(that means use qml in case transfer). have 1 issue: pass qimage value, , know can't pass arguments qml c++ using references , pointers.

so, whether there trick allows avoid objects copying during passing c++ qml , again c++?

the "trick" built in qt: many other classes contain data, qimage uses implicit data sharing aka copy-on-write/cow, quote qt5 docs:

qimage objects can passed around value since qimage class uses implicit data sharing.

link in docs provides more details means in context of qt, in short actual qimage instance small , cheap pass around value. pointer shared data reference count. when instance modified, detached (deep copy taken) first if reference count greater 1, when not modifying, it's copying around pointer.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -