0
votes

I'm using WebEngine in QML. Is there a way to change what gets displayed when there is a bad URL? It currently says something like:

This site can’t be reached
The webpage at qrc:/blahblah.html might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_URL

which is inappropriate because it's not a web site, just a QML resource which is missing. Either a QML or a C++ solution would be welcome.

1

1 Answers

1
votes

For Qt WebEngine it is an invalid resource so it indicates that it is an invalid URL. A possible solution is to detect the error and load the desired HTML.

WebEngineView {
    anchors.fill: parent
    url: "qrc:/blahblah.html"
    onLoadingChanged: {
        if(loadRequest.status === WebEngineLoadRequest.LoadFailedStatus){
            var html = loadRequest.errorString;
            console.log(loadRequest.errorDomain)
            loadHtml(html);
        }
    }
}