k.S
k.S

Reputation: 99

Type of objects passed from Qml to C++

When passing an object from Qml to C++ am I passing the object itself or a pointer to it? Example: I have a C++ slot which i call from within a Qml file and pass an argument to it. What am i passing to the slot, the object or a pointer to it?

Upvotes: 0

Views: 277

Answers (1)

dtech
dtech

Reputation: 49329

It depends on what you are passing. QObject derived types are intrinsically non-copyable, and as such are passed by pointer.

JS objects may be received as QVariant or QVariantList for arrays and QVariantMap for Objects. Those are passed by value and are copies of the passed data. There is also the possibility to use QJSValue.

There is a number of object types which are converted to their analogous types, you can see the full list in the official documentation.

Upvotes: 6

Related Questions