Qmllint Warnings for rootcontextproperty
-
Hello there,
I am porting my qml application from qt 6.7 to 6.8 LTS and found lot of warnings because of qmllint. I need to resolve these warnings-
First I am seeing for all the contextProperty that i have implemented for example the in the following code I have used "my_model" for mymodel object.
Engine->rootContext()->setContextProperty("my_model", &mymodel);
When I am using "my_model" in qml it is showing warning as "Unqualified Access".
Text{
text:my_model.name
}How Can I remove this warning ? Pls suggest
-
Hi,
Please use the code (
</>
) tags.The general advice is to avoid context properties. Embedding C++ Objects into QML with Context Properties spells out a few reasons, including the one noted here.
My preferred fix is to declare a property within the item, and then set it using an API such as QQmlComponent::createWithInitialProperties()