Paul DeRocco
Paul DeRocco

Reputation: 413

How to change QML WebEngineView URL error page

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.

Upvotes: 0

Views: 1548

Answers (1)

eyllanesc
eyllanesc

Reputation: 244202

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);
        }
    }
}

Upvotes: 1

Related Questions