1
votes

Subj I show my data on QML' Listview with delegated text, labels, and spinboxvalue elements of item. When user change the value of spinbox I need to know it and make some deals. But MouseArea works beyond of Spinbox, not on spinned buttons, onClicked event doesn't exists.

SpinBox {
                    id: goodsCountSpinBox
                    leftPadding: 1
                    rightPadding: 1
                    value: model.goodsCount
                    implicitWidth: 100
                    anchors.right: dataRow.right
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            listView.currentIndex = index; //Change the current selected item to the clicked item
                            console.log("SpinBox::MouseArea::onClicked")
                        }
                    }

By the way, and how to out current datetime in console log?

I found onValueChanged in examples but I don't find it in QML manuals.

  SpinBox {
            id: fontSizeSpinBox
            activeFocusOnPress: false
            implicitWidth: 50
            value: 0
            property bool valueGuard: true
            onValueChanged: if (valueGuard) document.fontSize = value
        }

I found to print current timestamp

   Qt.formatTime(new Date()
1
onValueChanged is a property change signal handler.mcchu
thanks. it is a common information for all class objects. now I understand on<Property>Changed where <Property> is the name of the propertyCat Vasey

1 Answers

2
votes

If you want to just use the current value of the spinbox, just use its value property in a binding.

If you want to react to the value change, use the handler for the property's change signal, i.e. onValueChanged.