我对 WebEngineView 有一些不便。我将它像其他元素一样放置在滚动视图中。只需要播放一些 YouTube 视频即可。 因此,当我滚动 ScrollView 时,当鼠标位于 WebEngineView 区域上时,它将不再滚动。
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ScrollView
{
id: myScrollView
anchors.fill: parent;
Rectangle
{
...
}
Text ...
Text ...
other stuff
WebEngineView
{
id: myWebEngineView
Component.onCompleted:
{
loadHtml(model.modelData.someHTMLData);
}
}
}
}
正如我所发现的。您可以在 WebEngineView 上执行
enabled = false
。但这使得它无法点击。我也尝试在其中添加 MouseArea,但没有帮助。将其包装在 Item 中也不起作用。
我能够让它与
Flickable
一起工作:
Flickable
{
id: myScrollView
anchors.fill: parent
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AlwaysOn; width: 20 }
clip: true
contentWidth: myWebEngineView.width
contentHeight: myWebEngineView.height
WebEngineView
{
id: myWebEngineView
width: myScrollView.width - 20
height: Math.max(contentsSize.height, 500)
Component.onCompleted: url = "https://stackoverflow.com/questions/78632674/qml-webengineview-cant-be-scrolled-in-scrollview-flickable-too"
}
}