C++ class members from qml
I want to read Q_PROPERTY of a member object, and display it in qml.
I have a class A witch has a private member object from class B like this :
//Q_PROPERTY QString localS = "localOK" this will work in qml : a.getLocalS
B *b // class B has Q_PROPERTY QString testStr = "test" and getTestStr() getter
In main.cpp, i set an instance of class 'A' in contextProperties
Now in main.qml i want to read b objects testStr
//text : a.getLocalS this is OK
text:a.b.getTestStr // this will not work
How can i access b by a ?
Is it possible to create Q_Property in A, witch returns my b ?
Q_PROPERTY(B myB READ getB )
and then do :
thank you in advance
From Qt's doc:
if the class itself is to be used as a method parameter or property, or if one of its enum types is to be used in this way — then the class may need to be registered.
@medyakovvit Thx very much this is exactly what i was reading now ! :)
I will try this tomorrow