我想在QML中創建不同的上下文菜單,但我不知道什麼是正確的語法。我想這樣做:如何指定條件ActionSets?
contextActions: [
ActionSet {
title: "Action Set"
subtitle: "This is an action set."
actions: if (_corporate.currentView == 2) {
[ ActionItem { title: "Action 1" },
ActionItem { title: "Action 2" },
ActionItem { title: "Action 3" } ]
} else {
[ActionItem { title: "Action 4" },
ActionItem { title: "Action 5" },
ActionItem { title: "Action 6" }
]
}
} // end of ActionSet
] // end of contextActions list
這顯然是錯誤的語法,那麼什麼是正確的方法是什麼?提前致謝!
謝謝!根據場景(如_corporate.currentView),不同數量的ActionItems怎麼樣? – Eir