how to load html,css and JS file for webView from qrc on android
Solved
Mobile and Embedded
-
I have a small website which I made for MicroProject for college . Now I just want to give for Android MicroProject cause I am lazy. So I have used WebView and it worked on Desktop . But When I compile it for android I get
here is the code :-
main.qml:-
import QtQuick 2.11 import QtQuick.Window 2.11 import QtWebView 1.1 Window { id: window visible: true width: 640 height: 480 title: qsTr("Stack") WebView{ id:webView anchors.fill:parent objectName: "webView" } }
main.cpp:-
#include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <QtWebView/QtWebView> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QtWebView::initialize(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); qDebug() << "engine:- "; QObject *root = engine.rootObjects().front()->findChild<QObject*>("webView"); qDebug() << root ; root->setProperty("url",QUrl("qrc:/EditorsWar/index.html")); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
I don't understand why this is not working on android but works on Desktop (ArchLinux/KDE)