Você pode usar o poderoso método Qt.createQmlObject () para preencher dinamicamente a lista de ações com o resultado de uma função JS, assim:
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
Rectangle {
id: mainView
width: units.gu(30)
height: units.gu(40)
ActionSelectionPopover {
id: actionSelectionPopover
}
Button {
id: actionSelectionPopoverButton
text: i18n.tr("action list")
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: units.gu(16)
function my_actions(){
var actions = []
for (var i = 1; i <= 5; i++){
var text = ['import Ubuntu.Components 0.1; Action {text: "', i.toString(), '";}'].join('')
actions.push(Qt.createQmlObject(text, actionSelectionPopoverButton, "action"+i));
}
return actions;
}
onClicked: {
actionSelectionPopover.actions = my_actions()
actionSelectionPopover.caller = actionSelectionPopoverButton;
actionSelectionPopover.show();
}
}
}