Hi Thomas, If the item you want to refer to has an id (not dynamically created) you can give the "rootitem" in your main.qml and id and then simply refer to it or bind other properties to it by it's id.
For example: First.qml: import Qt 4.7 Item { id: screen width: 500 height: 300 Second { id: secondItem } MouseArea { anchors.fill: parent onClicked: secondItem.bar(); } } Second.qml: import Qt 4.7 Item { property int foo: screen.width function bar() { console.log(foo); console.log(screen.width); } } Hope this helps. Juha On Mon, Nov 8, 2010 at 5:33 PM, Thomas PABST <thomas.pa...@gmail.com> wrote: > Hi, > > I recently discover the new QML language. I try to find the better way to > make modular software. I currently trying to find how to get value of > variables without entering the same value twice in another item, for example > the size of the main screen. I would like to get the value of variables by > calling a method. Using parent object isn't always possible (ie QML > Component Element) and it is very heavy to call the parents' variables when > we have a multi-level tree. > > main.qml >> >> Item { >> height: 480; >> width: 800; >> HomeFrame{ >> } >> } > > > HomeFrame.qml >> >> HomeFrame{ >> Rectangle{ >> ... some info... >> >> Widget{ >> >> >> >> } >> >> } >> } > > Widget.qml >> >> Widget{ >> >> property int width; >> >> width: //How call the main.qml => item=>width ?? >> >> } > > I wonder if it's possible only using QML or if we need to use qt/c++ ! > > Something like that : > > Widget.qml >> >> Widget{ >> >> property int width; >> >> width: screen.getwidth(); > > } > > Thanks > > > ----------------------------------------------------- > Thomas PABST > thomas.pa...@gmail.com > > _______________________________________________ > Qt-qml mailing list > Qt-qml@trolltech.com > http://lists.trolltech.com/mailman/listinfo/qt-qml > > _______________________________________________ Qt-qml mailing list Qt-qml@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-qml