maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   QML webview unable to load from html property or file:// URL (https://talk.maemo.org/showthread.php?t=72375)

cb22 2011-04-20 21:00

QML webview unable to load from html property or file:// URL
 
I figured I'd post here before reporting a bug - seeing as how someone may have some more insight into this.

Running the following (be it from Python or qmlviewer directly) works great on both my desktop and my N900:

Code:

import Qt 4.7
import QtWebKit 1.0

Rectangle{
        WebView {
            id: webView
            url: "http://www.google.co.za"
            width: 800
            height: 480
            //html:  "<html><body>I LIKE PIE<br><br><br>PIEPIEPIE!</body></html>"
        }
    }

However - the following ONLY seems to work on my desktop:
Code:

import Qt 4.7
import QtWebKit 1.0

Rectangle{
        WebView {
            id: webView
            //url: "http://www.google.co.za"
            width: 800
            height: 480
            html:  "<html><body>I LIKE PIE<br><br><br>PIEPIEPIE!</body></html>"
        }
    }

and ditto for
Code:

import Qt 4.7
import QtWebKit 1.0

Rectangle{
        WebView {
            id: webView
            url: "file:///tmp/test.html"
            width: 800
            height: 480
            //html:  "<html><body>I LIKE PIE<br><br><br>PIEPIEPIE!</body></html>"
        }
    }

It seems as if the WebView on the N900 only works when its loading something from the internet?

marxian 2011-04-20 21:22

Re: QML webview unable to load from html property or file:// URL
 
Setting the HTML worked for me (in the QMLViewer), but I needed to insert a <font color='white'> tag:

Code:

import QtQuick 1.0
import QtWebKit 1.0

WebView {

    width: 800
    height: 480
    html : "<html><body><font color='white'>I like pie<br><br><br>piepiepie!</font></body></html>"
}

http://img688.imageshack.us/img688/8...1042021211.png

I think the problem is that you have not set the width and height properties of the rectangle, so it defaults to 0 * 0. You should set the rectangle to 800 * 480, and use anchors.fill: parent for the webView.

cb22 2011-04-20 21:27

Re: QML webview unable to load from html property or file:// URL
 
Quote:

Originally Posted by marxian (Post 992831)
Setting the HTML worked for me (in the QMLViewer), but I needed to insert a <font color='white'> tag:

Code:

import QtQuick 1.0
import QtWebKit 1.0

WebView {

    width: 800
    height: 480
    html : "<html><body><font color='white'>I like pie<br><br><br>piepiepie!</font></body></html>"
}

http://img688.imageshack.us/img688/8...1042021211.png

That seems so obvious - yet I would've never have gotten it... I guess because in QML most things defaulted to white, I figured the webview would've done the same! Haha, I should go rest for a bit...

Many thanks :)


All times are GMT. The time now is 01:14.

vBulletin® Version 3.8.8