有没有办法覆盖ComboBox的MouseArea以忽略滚轮事件而不是更改当前索引? ComboBox本身没有选项可以更改滚轮焦点行为。 到目前为止,我尝试使用以下代码覆盖CB MouseArea中的onWheel:
ComboBox {
Component.onCompleted: {
for (var i = 0; i < combobox_ctrl.children.length; ++i) {
console.log(combobox_ctrl.children[i])
console.log(combobox_ctrl.children[i].hasOwnProperty('onWheel'))
if (combobox_ctrl.children[i].hasOwnProperty('onWheel')) {
console.log(combobox_ctrl.children[i]['onWheel'])
combobox_ctrl.children[i]['onWheel'] = function() { console.log("CB on wheel!") }
//combobox_ctrl.children[i]onWheel = function() { console.log("CB on wheel!")
//combobox_ctrl.children[i].destroy()
}
}
}
}
但是我遇到了
类型错误:无法分配给只读属性“wheel”
有人能够在Qml中禁用ComboBox上的滚轮事件吗?
// 编辑
例如,在Slider控件中,我可以像这样删除滚轮事件处理:
Slider {
Component.onCompleted: {
for (var i = 0; i < slider.children.length; ++i) {
console.log(slider.children[i])
if (slider.children[i].hasOwnProperty("onVerticalWheelMoved") && slider.children[i].hasOwnProperty("onHorizontalWheelMoved")) {
console.log("Found wheel area!")
slider.children[i].destroy()
}
}
}
}
但是在滑块中,WheelArea不负责处理“click”事件。