Here's what I did: function unselectAllButton() { [idButton1, idButton2, ...].forEach(function(v){ v.checked = false; }); group.checkedButton = null; }
I didn't test it with ButtonGroup, but only with QtQuick Controls 1 and ExclusiveGroup work this way (change the group.checkButton for group.current), so I guess it should work too. [image: bodycad] <https://www.bodycad.com/> Jerome Godbout Software Developer 2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7 T: +1 418 527-1388 E: jer...@bodycad.com www.bodycad.com The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited. Le contenu de ce message et les pièces jointes sont destinés uniquement pour le(s) destinataire(s) et peuvent contenir des informations confidentielles et / ou privilégiées qui peuvent être protégées légalement contre toute divulgation. Si vous n'êtes pas le destinataire de ce message ou son agent, ou si ce message vous a été adressé par erreur, s’il vous plaît avertir immédiatement l'expéditeur par courriel de réponse, puis supprimer ce message et les pièces jointes. Si vous n'êtes pas le destinataire prévu, vous êtes par la présente informé que toute utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces jointes est strictement interdit. On Wed, Aug 16, 2017 at 7:46 AM, Bullinger, Julius < julius.bullin...@intel.com> wrote: > Hi, > > > > given the ButtonGroup example > <https://doc.qt.io/qt-5/qml-qtquick-controls2-buttongroup.html> from the > documentation: > > > > ButtonGroup { id: *group* } > > > > RadioButton { > > checked: true > > text: *qsTr*("Option A") > > ButtonGroup.group: *group* > > } > > > > RadioButton { > > text: *qsTr*("Option B") > > ButtonGroup.group: *group* > > } > > > > When the application is started, all buttons are unchecked (*group* > .checkedButton is null). As soon as a button is clicked, the > checkedButton is set, and selection can only be changed between buttons. > > > > Is there any way to uncheck a button, when it’s clicked in a checked > state? It’s supposed to work by setting *group*.checkedButton to null > again, but this doesn’t work when doing it on a Button signal. I tried > several approaches like these: > > > > Connections { > > target: *buttonGroup*.checkedButton > > onClicked: if(*buttonGroup*.checkedButton.checked) { > > *buttonGroup*.checkedButton.toggle() > > // or setting checked to true, > > // or moving the connection to each Button, > > // or using onPressed/onReleased, > > // or setting group.checkedButton to null > > // doesn’t work either > > } > > } > > > > But for all of these, the button is toggled checked > unchecked > checked > immediately when it’s clicked. > > > > It does work when omitting the ButtonGroup, but I need mutually-exclusive > selection. > > > > Thanks and best regards, > > Julius > > Intel Deutschland GmbH > Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Christian Lamprechter > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928 > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest