[Qt-qml] Trying hard to get WebView to work from a QML only program on N900 with Qt 4.7

Sacha Zyto sacha at mit.edu
Thu Jul 22 16:34:58 CEST 2010


Hi Warwick,

On 07/21/2010 07:17 PM, warwick.allison at nokia.com wrote:
>> import org.webkit 1.0 //_QML
>> //_CPP import QtWebKit 1.0
>>      
> Just use a new enough build of Qt 4.7 on both and you'll not have to do this.
>
> The module is called "QtWebKit" for the 4.7.0 release. It was called "org.webkit" in some past beta release.
>
> --
> Warwick
>    

This is right, but I find the sed trick useful for another use case that 
has made my UI design much more pleasant:  in order to be able to run my 
app with qmlviewer alone, for example to use the new upcoming 
"Firebug-like features a-la-qml :)".

For instance, the complete app (C++ with with QML running from a 
QDeclarativeView) has some extra features such as a Calendar module 
(which basically displays a QCalendarWidget and defines a few signals 
and slots so that my QML-based app can read the date from that calendar).

When I run my project from qmlviewer though, there's no way (I think) to 
display that same QCalendarWidget, but if I didn't do anything the 
"import Calendar 1.0" wouldn't be resolved, and my app wouldn't run from 
qmlviewer. So I've defined a Calendar module inside a "Mockups" 
directory, which just displays the image of a calendar and contain 
canned values for properties like the date etc... (this is basically my 
UI mockup prototype).

Now, whenever I need to use the Calendar module in my qml files, I 
import it using the same trick:

import "../Mockups" //_QML (-> this is the directory that contains the 
mockup Calendar module, that I only use when run from in qmlviewer)
//_CPP import Calendar 1.0

This way, I get best of both worlds: the Qt Designer to design my 
C++-based widgets, the QTCreator QML Designer to design my QML-based 
widgets, and being able to debug the qml logic (albeit with canned values).

Once again, this is just a hack: If you know of a better way of doing 
that, I'd love to know about it. Remeber that I can't just package my 
C++ Calendar module in order for it to be seen by qml, because that very 
module is used to display a native Qt Widget.





More information about the Qt-qml mailing list