Important: Please read the Qt Code of Conduct -

QWebPage on Android

  • Hi all

    I'm currently developing an application using QWebPage. Under desktop systems it work very very well but now I "discovered" this class is not available in Qt for android platform (since part of WebKit). Looking around it seem in new upcoming Qt 5.4 a new component called QWebEngine will going to substitute QWebkit but still didn't understand if this new component will work under android too. There are many different news around and I'm a bit confused about this topic. In other pages it seem to suggest, in case of Android, use the QWebView component able to manage the native system browser. For me is not a problem to wait for release of 5.4 version but my problem is in my software I use QWebPage (since I don't want to show a website page but need only to "internally" manage it) and, in particular, is mandatory the feature of this component to exchange data between C++ and javascript code.

    Does anyone know if in new upcoming 5.4 release will be a component (QWebEngine or QWebView or other) able to make same work of QWebPage (interna webpage management and interaction between C++/javascript) under android too?

    Thank you

  • Hi fpermana

    Thank you for your suggestion but, please note, I need same feature of QWebPage. The main difference with WebView component is that QWebPage is not showed on the screen but work in background and return repaint event for inform that something is changed in the current web page and need to be redraw. Native android webview have similar feature using onDraw() event but the main problem is the onDraw() event is emitted only if the current webview control is showed on the screen. If this is hidden in backround as I need the draw event will not emitted...

  • may I know what do you want to achieve with onDraw()?
    did your content of webview is dynamic or static?

    I'm able to create an apps that fetch json data from web server using QNetworkAccessManager, and show it on the webview.
    I keep the string value, and when webview is shown, I can change the content with that value.

    I had to do it that way, because my web content contains more than one animated gif images.
    The only way to make them animated is only with webview.

  • Hi

    I need to use webkit to manage some online maps. The problem of this web page was the code of the page is quicky loaded but, since there are a lot of images composing the map, not all the images are loaded instantly. I need to know exacly when all the images are loaded before get screenshot. Using QWebPage component is very easy since there is the "repaintrequest" event that inform me every time there is a change in the web viewport. Unfortunately QWebPage is not available in android. Same result can be reached using onDraw() from native webview component but in my application the viewport managing the web page must be hidden and in android (like Windows too) when a component is in invisible state no draw event is emitted since there is no need of it.

  • It's similar to what happened to me.
    What I did was I fetch the content using QNetworkManager, find the img tag using regex, download all images from its src attribute using QNetworkManager again and save them to sdcard.
    when all images downloaded, you can "refresh" webview by change its data.
    @m_webView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);@
    where baseUrl is your path to all images you saved.
    but I didn't know will it worked on map.

    And also, I think you don't need to hide by using visibility, you can just move it to somewhere not visible on screen.
    Maybe something like this.
    @Window {
    id: webViewWindow
    WebView {
    y: height: Screen.height
    x: width: Screen.width

    also not tested yet.

  • Hi

    I didn't try to move the view out of the screen but I don't think will work as you can see from the documentation following:


    It's the normal behaviours of any OS, if the window is not visible stop to redraw for avoid unnecessary CPU work.

  • I think you need to try anything possible if you really want to port your app to android.

    I've just tested it with google maps using QtWebview. When I hide the webview (move the view out of the screen), I also change its url to some city.
    I got output from QtCreator Application Output tab something like this.
    @E/CallbackProxy(13271): UPDATE_URL@
    And when I show the webview, the maps already loaded to the city on the url.
    But I don't know if this is similar to what you want to do since I do not know what your app is.

  • In your test you basically tried if the "web engine" is able to work if the view is out of the screen and I expect it to work since the thread is active. The problem is you don't have "updates" regarding he current status of the map screen image painted. This is what I miss and I need for my app...
    Anyway thank you for your time :)

Log in to reply