[Development] [Interest] qtwebview with qtwebchannel
Sylvain Pointeau
sylvain.pointeau at gmail.com
Sun Sep 16 11:49:33 CEST 2018
> > Are you sure the WebView can load from the resources (url:
> “qrc:/index.html)?
>
> I knew it cannot (does qrc:/ work on iOS at all?), but I was silently
> waiting for someone to provide the way it should be done on iOS :)
> Unfortunately no-one did, so apparently it’s a bigger problem than I
> thought.
> And what I did - just served index.html and qwebchannel.js via regular
> webserver (lighttpd) from my machine
OK, now I understand why I do have a different result than you.
The use case is then different, I would not expect an app to run HTML from
a server but embedded into the app itself. Additionally I gave the solution
how to extract the HTML into the local folder and load from there.
> qDebug() << QFileInfo(tmpdir.absolutePath()).absoluteFilePath();
>
> QDirIterator it(":"/*, QDirIterator::Subdirectories*/);
> while (it.hasNext()) {
> QString tmpfile = it.next();
> QFileInfo file = QFileInfo(tmpdir.absolutePath() +
tmpfile.right(tmpfile.size()-1));
> QFile::remove(file.absoluteFilePath()); // remove previous file
to make sure we have the latest version
> QFile::copy(tmpfile, file.absoluteFilePath());
> qDebug() << tmpfile;
> }
> .....
> QQmlContext *context = engine.rootContext();
> context->setContextProperty(QStringLiteral("mylocalpath"),
QFileInfo(tmpdir.absolutePath()).absoluteFilePath());
> @qt developers, please could you confirm if the webchannel is working or
> not on ipad (with the webview)?
>
> So I can confirm that WebChannel over WebSocket communication does work
> with WebView on iOS.
>
More precisely, you confirm that the webchannel is working if the page is
loaded from a server.
and I confirm that it does not work if the page is loaded from the
filesystem.
It is a terrible news for me, there are so many use cases where I need to
run HTML pages which are downloaded or created by the app. I need to be
able to communicate between the HTML and the backend, to store values
locally and provide content.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20180916/0984d553/attachment.html>
More information about the Development
mailing list