[Qt-qml] question about how to assign a delegate
Johannes Zellner
johannes.zellner at nokia.com
Wed Dec 28 12:00:51 CET 2011
Hi,
On 12/28/2011 10:52 AM, ext Sivan Greenberg wrote:
> Hi All,
>
> I've been recently playing with the wonderful RSS reader example that
> is shipped with Creator part of the SDK, and I noticed (in contrast
> with old examples) that the delegates in the example are assigned as
> such:
>
> ListView {
> focus: true
> id: categories
> anchors.fill: parent
> model: rssFeeds
> footer: quitButtonDelegate
> delegate: CategoryDelegate {}
> highlight: Rectangle { color: "steelblue" }
> highlightMoveSpeed: 9999999
> }
>
> Notice the {} braces after the delegate assignment, now with the the
> braces the listview shows no content, so they are required. Has this
> changed in QML over the last months or just something I overlooked ?
> What's the semantic meaning of that? Perhaps this means to
> "instantiate" the delegate and have the delegate property reference
> it? (Much like you do in Python, where you do obj = Object())
As you already suspected, the "CategoryDelegate{}" in this case means,
that an instance of this Component will be created and assigned to the
delegate property. Without the braces, it tries to find an instance of a
Component with the "id: CategoryDelegate".
In this case for the "footer" it references "quitButtonDelegate" by ID.
Johannes
More information about the Qt-qml
mailing list