Important: Please read the Qt Code of Conduct -

QML android webview error

  • Hello,

    I m trying to display some local html / css file but I get an "ERR_UNKNOWN_URL_SCHEME

    I use this to import the html css file on my .pro

    deployment.files += test.html
    deployment.files += test.css
    deployment.path = /assets
    INSTALLS += deployment

    my c++ file :

    QFile file( "assets:/test.html" );
          if( !file.exists() )
            qDebug() << "---------The file" << file.fileName() << "does not exist.-----------------";
          else qDebug() << "---------The file" << file.fileName() << "exist.-----------------";
          engine.rootContext()->setContextProperty("pathToFile", "assets:/test.html");

    my .qml file :

    WebView {
                    id: webview
                    url: pathToFile
                    anchors.fill: parent

    I know that the files exists, but I dont know why it didnt work .... thanks for your help

  • Hi! Your file path in QFile(...) is correct but when you need an URL for an asset on Android then you have to use file:///android_asset/.... So, assuming your test file is assets:/data/test.html, the correct URL is:

    WebView {
      url: "file:///android_asset/data/test.html"

  • @Djeff said in QML android webview error:


    This error is appeared because the WebView can’t recognize the URL Scheme,for example, the WebView will usually recognize only http and https, anything other than these. So WebView cannot parse it to right place, we should use intent to redirect the url. for example – intent://,market://,app://,mail:// etc will not be recognized by webview unless we add a handler to handle these url scheme or by disabling these schemes and only load http and https schemes.

    This error has no any specific solution till now. Android user and PC user all are facing this error which needs to be sought out. There's a long-standing bug in Chromium regarding how links without protocols are handled. It occasionally is patched, but seems to keep resurfacing. In some cases, prefixing your links with http:// (or https://) should resolve the issue for you.

    Also, in some cases, try to add target="_blank" in your URL Scheme/Code. for example:

    <a href="" target="_blank">Link Text</a>

Log in to reply