Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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 usefile:///android_asset/...
. So, assuming your test file isassets:/data/test.html
, the correct URL is:WebView { url: "file:///android_asset/data/test.html" }