Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
Qt for MCUs 2.5
-
None
Description
*I have attached the project and the generated C++ code by qmltocpp, respectively, "Buttons.zip" and "Buttons.dir.zip."
What the sample application does is to present three CheckBoxes and a Button.
When the user clicks on the Button, the application outputs the number of checked CheckBoxes, like so:
import QtQuick import QtQuick.Controls Rectangle { width: 480; height: 272 Column { CheckBox { id: checkbox1 text: checked ? "checked" : "unchecked" } CheckBox { id: checkbox2 text: checked ? "checked" : "unchecked" } CheckBox { id: checkbox3 text: checked ? "checked" : "unchecked" } Button{ text: "Calculate" property int numChecked: 0 onClicked: { numChecked = checkbox1.checked ? 1 : 0 + checkbox2.checked ? 1 : 0 + checkbox3.checked ? 1 : 0; console.log("The number of checked checkboxes = " + numChecked); } } } }
The issue is, even when more than 1 CheckBoxes are checked, the application always outputs The number of checked checkboxes = 1.
When none of the CheckBox is checked, it properly outputs The number of checked checkboxes = 0.
I checked the concerning part of the generated code(
void Buttons::button_onClicked_bindingFunctor::operator()() const in Buttons.cpp), and found out that the operations were wrong, as in it always adds 1 to 0, therefore, the application cannot output the value more than 1, even when more than 1 CheckBoxes are checked.