import QtQuick import QtQuick.Controls import QtQuick.Layouts SpinBox { id: spinBox width: 100 height: 30 editable: true MouseArea { anchors.fill: parent onWheel: (wheel)=> { if (wheel.angleDelta.y > 0) { if (spinBox.value === spinBox.to) { // 当当前值等于最大值时 spinBox.value = spinBox.from // 增加时跳转到最小值 } else { spinBox.value++ // 当滚轮向上滚动时增加值 } } else { if (spinBox.value === spinBox.from) { spinBox.value = spinBox.to // 当当前值等于最小值时,减少时跳转到最大值 } else { spinBox.value-- // 当滚轮向下滚动时减小值 } } } } }