PDA

View Full Version : QML WebEngineView auto-adjust size



zethon
23rd March 2017, 00:26
I have a bunch of WebEngineViews in a ListView. For example:


ListView
{
model: myModel
delegate: Component
{
Item
{
WebEngineView
{
id: myWebView
Component.onCompleted: loadHtml(model.modelData.htmlText, baseURL)
}
}
}
}

How can I adjust the height of the Item once the html is loaded? The HTML in question may include images, so I want to resize the WebEngineView once everything is loaded. I suspect I can do something like:


ListView
{
model: myModel
delegate: Component
{
Item
{
WebEngineView
{
id: myWebView
Component.onCompleted: loadHtml(model.modelData.htmlText, baseURL)
onLoadingChanged:
{
if (!loading && loadRequest.status == WebEngineView.LoadSucceededStatus)
{
height = ????
}
}
}
}
}
}

But I'm not sure to what I should set height.