Important: Please read the Qt Code of Conduct -

QML WebengineView does not return http page errors

  • Hi So I am new to QML but it seems straight forward to me.
    I am tring to create a simple single windows browser window that displays our webpage and runs on a arm based linux system. I have gotten it to build both on our yocto build system and also on ubuntu linux with version 5.5.1 and 5.6.2 on ubuntu.
    I need to beable to detect the error page so i can then load a custom HTML page

    I just used the example code to start with and added a couple of keys to change page and see the reponses , code shown below. One action changes to an invalid page which returns the HTTP 404 error page and it reports nothing in the onLoading changed. no error code and domain.

    So then I noticed the settings.errorPageEnabled which i then set to false hoping now it would give me an error code etc. yet it does not it always displays the error page and does not report any error codes. It just says the page loaded correctly when it clearly has an 404 http error , yes it loaded the error page correctly.

    I have been digging around in the source code and the errorPageEnable setting seems to be some sort a test attribute but why it seems like a standard thing to want to know if the web page you just set actually loaded correctly

    So how do I make to api function work? or is it broken

    import QtQuick 2.0
    import QtQuick.Window 2.1
    import QtWebEngine 1.2
    import QtQuick.Controls 1.0
    Window {
    id: mainWindow
        width: 800
        height: 600
        visible: true
        WebEngineView {
            id: mywebEngineView
            anchors.fill: parent
            settings.errorPageEnabled: false
            url: "http://localhost/gdm/index.htm"
            onLoadingChanged: {
                print("onloadingchanged called ")
                if (loadRequest.status === WebEngineLoadRequest.LoadFailedStatus)
                    print("url " + loadRequest.url + " Domain " + loadRequest.errorDomain)
                    if ( loadRequest.errorDomain == WebEngineView.HttpErrorDomain )
                        print("http error")
                    print("load status failed")
        Action {
            id: refreshTrademe
            shortcut: "Ctrl+L"
            onTriggered: {
                mywebEngineView.settings.errorPageEnabled = false;
                mywebEngineView.url= ""
        Action {
            id: errorPageTest
            shortcut: "Ctrl+M"
            onTriggered: {
                mywebEngineView.url= "http://localhost/gdm/index.htm"

  • The solution for me was to use a XMLHttprequest which does return the http status codes to request my page and using that information it can then decide which page the webengine view would display. Either a real page from the server or a custom error page.
    It would be nice if the loadrequest errorcode etc actually worked as during my limited testing it would always return nothing usefull . No errorDomain, no errorCode and no errorString

Log in to reply