我正在使用 qt quick controls 2 SplitView
,似乎 SplitView
项内的任何 MouseArea
都将鼠标事件从SplitView
句柄。这意味着当 handle 位于具有 MouseArea
的组件上方时,无法拖动 handle ,例如Button
,在 SplitView
的项目内。
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.13
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
SplitView {
id: splitView
anchors.fill: parent
handle: Rectangle {
id: handle
implicitWidth: 20
color: "red"
}
Page {
id: firstPage
Button {
id: button
implicitWidth: 100
implicitHeight: 50
text: "button"
}
}
Page {
id: secondPage
}
}
}
正常行为:
按钮阻止来自句柄的鼠标事件:
我尝试将 splitView
和 handle
的 z 值设置为大于 firstPage
和 button
的 z 值但这没有用。
最佳答案
Page {
id: firstPage
clip: true
Button {
id: button
implicitWidth: 100
implicitHeight: 50
text: "button"
}
}
您必须在页面上激活剪辑。 我在一个空的 projet 上测试它工作。:D 我想 handle 栏下加载按钮的右侧仍然处于事件状态。 (如果有人确切知道为什么发表评论)
关于qt - SplitView 项目内的 MouseArea 将鼠标事件从 Splitview 句柄中移走,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64163192/