【发布时间】:2016-11-19 11:06:35
【问题描述】:
主题 我在 QML 的 Listview 上显示我的数据,其中包含项目的委托文本、标签和 spinboxvalue 元素。当用户更改 spinbox 的值时,我需要知道它并进行一些交易。但是 MouseArea 在 Spinbox 之外工作,不在旋转按钮上,onClicked 事件不存在。
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")
}
}
顺便问一下,如何在控制台日志中输出当前日期时间?
我在示例中找到了 onValueChanged,但在 QML 手册中没有找到它。
SpinBox {
id: fontSizeSpinBox
activeFocusOnPress: false
implicitWidth: 50
value: 0
property bool valueGuard: true
onValueChanged: if (valueGuard) document.fontSize = value
}
我发现打印当前时间戳
Qt.formatTime(new Date()
【问题讨论】:
-
onValueChanged是property change signal handler。 -
谢谢。它是所有类对象的公共信息。现在我了解
Changed where 是属性的名称
标签: qt events qml qtquick2 qtquickcontrols