Hi Kai,

Le 26/02/2016 11:15, Koehne Kai a écrit :

-----Original Message-----
From: Development [mailto:development-
[email protected]] On Behalf Of
Fabrice Salvaire
Sent: Thursday, February 25, 2016 1:33 PM
To: [email protected]
Subject: [Development] Though about rich text (html, WebView) rendering

Dear all,

I am investigating to port a content server to an off-line mobile application
in order to don't rely to a network connection at all. Thus I have to port a
database, a kind of web framework, a template engine and a rendering
engine. I believe it can be a use of case of Qt on mobile platform.

If we consider HTML is the right way to display rich text there is actually to
solution with Qt : Text for basic HTML and WebView for a full compliance. I
am not sure to understand why we cannot use WebEngine on mobile
platform. WebEngine seems more interesting since it provides WebChannel
hooks.
Let's be clear here on the terminology: With "WebView" I assume you refer
to Qt WebView (http://doc.qt.io/qt-5/qtwebview-index.html), which on Android
integrates the native browser. Since Qt WebChannel can use WebSockets as
a means of communciation, you can use it with Qt WebView on Android, too.
You'd need to set up a local websocket server though ("ws://localhost/...").
Not sure how exactly that works for an Android app.

Ok, I could investigate this.


Qt WebEngine is indeed currently only supported for Windows, OS X and
Linux. Porting it to Android is possible, but a lot of work.

Thus android and ios don't forbid it.

I succeed to hack the WebView using the loadingChanged signal in order to
simulate a dynamic HTML framework, i.e. call loadHtml according to the url.
But I don't known if it is the right way to achieve this. Maybe we can extend
the Java wrapper for this purpose? The fact the rendering surface is a light
web browser behind the scene can be disturbing since it doesn't integrate
very well with the QML application.
I'm not sure I really understood what you've been doing with the loadingChanged
Signal.

What I did basically to catch page loading and set the content according to the url ( WebView get page -> LoadingChanged signal -> call loadHtml -> ... ) :

    function handle_loading(load_request) {
if (load_request.url == "qrc:/index.html" && load_request.status == 0) { var html_content = "<h1>Main Page</h1><p><a href=\"page1\">A link</a></p>";
        }
        if (load_request.url == "qrc:/page1" && load_request.status == 0) {
            var html_content = "<h1>Basic HTML</h1>";
        }
        var base_url = "qrc:/";
        web_view.loadHtml(html_content, base_url)
    }

    WebView {
        id: web_view
        objectName: "web_view"
        anchors.fill: parent
        url: "qrc:/index.html"
        onLoadingChanged: handle_loading(loadRequest)
    }

I think there is something evil since a Web engine is a concurrent of QML.
What do you mean by that?

I am just thinking how to implement the power of HTML for text rendering in QML cleverly. And don't use any web framework for mobile platform.

Mathjax is a good example. How can we implement a computer algebra system //using Qt for example ?

We can render math formulas out of the box using a QML WebView and
mathjax, but we can also implement a full application using HTML5 and
javascript. Thus use a stack over a stack ...

What is the future plan and advices for this topic?
I'm afraid there are no direct plans to support Qt WebEngine on Android.
If I'd be you I'd try to set up a WebSocket. If that ain't possible you could
Still try to communicate between the WebView and your app
just via runJavaScript().

Regards

Kai

Fabrice
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to