0

If I have a WebEngineView in a ListView delegate, how can I call loadHtml when the delegate is loaded? For example:

ListView
{
    model: myModel

    delegate: Component
    {
        Item:
        {
            WebEngineView
            {
                id: myWebView
                text: myWebView.loadHtml(model.modelData.htmlText) 
            }
        }
    }
}

The above shows the idea of what I would like to do. Is there a signal I could hook into for each delegate Item where I could call myWebView.loadHtml()?

Addy
  • 2,414
  • 1
  • 23
  • 43

1 Answers1

1

I do not know about a text-property of the WebEngineView but I have never used it sofar.

I think, what you want is the Component.onCompleted-handler like this:

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

I don't know about your usecase, but the loadHtml-method has a second argument for the baseURL to look for ressources such as CSS or Images, which might be needed by you.