[SailfishDevel] Dynamically populate a ContextMenu
Tigre-Bleu
devel at tigre-bleu.net
Sat Nov 23 13:47:08 UTC 2013
Hi,
I try to dynamically populate a ContextMenu but either I ran into a bug in the Silica Component or there is something I'm doing wrong.
Here is an example of simplified code showing the problem:
ComboBox {
width: parent.width
label: "Menu"
menu: ContextMenu {
id: menu
MenuItem { text: "Static 1" }
MenuItem { text: "Static 2" }
}
Component {
id: menuItemComp
MenuItem {}
}
Component.onCompleted: {
console.debug("Populating menu")
for (var i=0; i< 4 ; i++){
var newMenuItem = menuItemComp.createObject(menu, {"text" : "Dynamic" + i})
}
}
}
And in attachment is the result in the emulator.
We see that Static entries are correctly displayed, but dynamic ones are all superposed.
What is wrong?
Thanks,
Antoine
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QML Context Menu.png
Type: image/png
Size: 204826 bytes
Desc: not available
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20131123/c3594a45/attachment.png>
More information about the Devel
mailing list