我在ListView中有一堆WebEngineViews。例如:
ListView
{
model: myModel
delegate: Component
{
Item
{
WebEngineView
{
id: myWebView
Component.onCompleted: loadHtml(model.modelData.htmlText, baseURL)
}
}
}
}
加载html后,如何调整项目的高度?有问题的HTML可能包含图像,所以我想在加载所有内容后调整WebEngineView的大小。我怀疑我可以做类似的事情:
ListView
{
model: myModel
delegate: Component
{
Item
{
WebEngineView
{
id: myWebView
Component.onCompleted: loadHtml(model.modelData.htmlText, baseURL)
onLoadingChanged:
{
if (!loading && loadRequest.status == WebEngineView.LoadSucceededStatus)
{
height = ????
}
}
}
}
}
}
但我不确定应该设置什么高度。
答案 0 :(得分:0)
我能够像`onContentsSizeChaged'一样做我想做的事情:
ListView
{
model: myModel
delegate: Component
{
Item
{
WebEngineView
{
id: myWebView
Component.onCompleted: loadHtml(model.modelData.htmlText, baseURL)
onContentsSizeChanged:
{
myWebView.height = contentsSize.height;
}
}
}
}
}