On the C++ side I do this:
rootContext()->setContextProperty("foo", fooObject);
rootContext()->setContextProperty("foo", fooObject);
To copy to clipboard, switch view to plain text mode
Then in Qml I do this:
Item {
MyCPlusPlusObject { }
Text {
text: foo.someTextProperty
}
}
Item {
MyCPlusPlusObject { }
Text {
text: foo.someTextProperty
}
}
To copy to clipboard, switch view to plain text mode
Where MyCPlusPlusObject is a simple QObject based C++ object that is registered with qmlRegisterType. The question is how can I get a hold of the "foo" context property from inside the implementation of MyCPlusPlusObject. I need to somehow get a hold of the root context to get the property out of it.
Bookmarks