[Qt-qml] Iterating over a list of items

Pertti Kellomäki pertti.kellomaki at nokia.com
Thu Nov 18 10:36:15 CET 2010


More simple questions about idiomatic ways of doing things in QML...

Let's say I have a Menu element with property menuItems, which I want to 
use as follows:

     Menu { menuItems: [ MenuItem { label: "a"}, MenuItem { label: "b" } ] }

I want each MenuItem to have an attached property provided by Menu. Do I 
just write a javascript loop in Menu's onMenuItemsChanged handler to 
iterate over the menuItems list, or is there some more concise way to 
express this in QML?
-- 
Pertti




More information about the Qt-qml mailing list