Hi, simply assign id to one of the static items, e.g. firstStatic, and then use firstStatic.parent instead of menu._contentColumn as parent for the dynamic items -- this way you do not rely on implementation details:
menu: ContextMenu { id: menu MenuItem { id: firstStatic; text: "Static 1" } MenuItem { text: "Static 2" } } Component.onCompleted: { console.debug("Populating menu") for (var i=0; i< 4 ; i++){ var newMenuItem = menuItemComp.createObject(firstStatic.parent, {"text" : "Dynamic" + i}) } } Event better consider using Repeater and provide the list of dynamic items as item model[1] (assiging a number as a model gives exactly the same result as in your original example): ApplicationWindow { initialPage: Page { ComboBox { width: parent.width label: "Menu" menu: ContextMenu { id: menu MenuItem { text: "Static 1" } MenuItem { text: "Static 2" } Repeater { model: 4 MenuItem { text: "Dynamic " + index } } } } } } BR, Martin [1] https://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-repeater.html#model-prop On Saturday, November 23, 2013 04:06:40 PM christopher.l...@thurweb.ch wrote: > Hi Andrey > > Zitat von "Andrey Kozhevnikov" <coderusin...@gmail.com>: > > you may need to make childs of menu._contentColumn, not just menu. > > I thought that the underscore stuff are private internal properties / > functions that we mere mortals should not be using ....8-) (Not that > that would necessarily stop me). > > Chris > > > _______________________________________________ > SailfishOS.org Devel mailing list
_______________________________________________ SailfishOS.org Devel mailing list