return Myclass to qml
-
what is the best practice to return MYClass that is created in a method?
-
But I'm filling the object in a function, so I want to return that same object and receive it in javacript / QML.
But the object undergoes changes from the QML side after some calls to that function. In which I get the error: ASSERT: "! Create" in file ....This line can only be called in main.cpp
ApplicationData data;
view.rootContext () -> setContextProperty ("applicationData", & data);But my object was filled in function, so I can not use it.
Example of my class:
Help me
-
@Samuel-Costa said in return Myclass to qml:
But my object was filled in function
Can you show us the function signature?
-
This is my function :
-
At this point I'm just printing the object:
console.log("Here...... " + awi_base.getAwiProp("id_fld_51" , uiContext.currentAwiLabelDesignCanvas.awi_Base_Compound)) -
I added this line to my function:
QQmlEngine::setObjectOwnership(prop, QQmlEngine::CppOwnership);
and it worked -
Can I get the AWI_PROP object this way in QML / JavaScript ?
QML:
property AWI_PROP awi_prop_width
property AWI_PROP awi_prop_heightJavaScript:
onAwiBase_CompoundChanged: {
awi_prop_width = awiBase_Compound.getAwiProp ("id_fld_51")
awi_prop_height = awiBase_Compound.getAwiProp ("id_fld_52")
}