[Qt-qml] Recommended way to parametrize QML items?

Pertti Kellomäki pertti.kellomaki at nokia.com
Wed Nov 17 13:20:37 CET 2010


What is the recommended way to parametrize QML items? What I would like 
to achieve is something the following. The intent is to create a Foo 
where one part of the visual appearance is given by the bar property.

    Foo { bar: Text { text: "bar text" } }
    Foo { bar: Image { source: "bar-image.png" } }

Looking at SpinBox.qml in the custom branch of qt-components [1], I see 
that one way to do this is to use a Loader element as a place holder 
inside the definition of Foo, and set it up in the onLoaded handler. 
This is clear enough, though it does look like a bit roundabout way of 
doing things.

Is this the recommended way to achieve what I am after?

[1] <http://qt.gitorious.org/qt-components/qt-components/commits/custom>
-- 
Pertti




More information about the Qt-qml mailing list