RootContext method
-
Please have look again at "QDeclarativeContext class references":http://developer.qt.nokia.com/doc/qt-4.8/qdeclarativeview.html#rootContext:
bq. QDeclarativeContext * QDeclarativeView::rootContext () const
This function returns the root of the context hierarchy. Each QML component is instantiated in a QDeclarativeContext. QDeclarativeContext's are essential for passing data to QML components. In QML, contexts are arranged hierarchically and this hierarchy is managed by the QDeclarativeEngine.What is bothering you in this description?
-
... and make sure that you've followed the documentation to "QDeclarativeContext":http://doc.qt.nokia.com/4.8-snapshot/qdeclarativecontext.html and "QDeclarativeEngine":http://doc.qt.nokia.com/4.8-snapshot/qdeclarativeengine.html, which contain a brief explanation of both.
-
Different QDeclarativeContexts are organized the same way as QObjects are - as a tree. Each QDeclarativeContext has one parent context and n child contexts. As in every tree there is exactly one root element, which has n children, but no parent.
As each QDeclarativeEngine has its own context tree each QDeclarativeEngine has its own root context element, which is automatically created and accessible through QDeclarativeEngine::rootContext(). See "The Context Hierarchy":http://doc.qt.nokia.com/4.8-snapshot/qdeclarativecontext.html#the-context-hierarchy.
A "QDeclarativeContext":http://doc.qt.nokia.com/4.8-snapshot/qdeclarativecontext.html#details is used to pass data between QML and C++.