Exclusive menu item check-mark not working
-
I am running Qt 6.8 on ubuntu 22.04.3.
My QML dynamically adds checkable MenuItems to a menu, using Repeater and a model. I want those items to be exclusively checkable, but they are not; i.e. when I select an item, it becomes checked - as are all previously selected item:Menu { title: 'Mouse mode' id: mouseModesMenu Repeater { model: mouseModes visible: true MenuItem { text: modelData; checkable: true; ActionGroup.group: mouseModeActions onTriggered: { console.log('selected ', modelData); topoDataItem.setMouseMode(modelData)} } } } ActionGroup { id: mouseModeActions exclusive: true }
What am I doing wrong?
Thanks! -
C Christian Ehrlicher moved this topic from General and Desktop on
-
Use Actions inside the Repeater, associate them with the ActionGroup, and bind them to the MenuItem.
Menu { title: "Mouse mode" id: mouseModesMenu Repeater { model: mouseModes Action { id: mouseAction text: modelData checkable: true ActionGroup.group: mouseModeActions onTriggered: { console.log("selected", modelData) topoDataItem.setMouseMode(modelData) } } delegate: MenuItem { action: mouseAction } } } ActionGroup { id: mouseModeActions exclusive: true }