<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.6(BH)" -->
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>Planet Maemo: category &quot;feed:a55aba7f8b8bee845720e26917ca5d02&quot;</title>
        <description>Blog entries from Maemo community</description>
        <link>http://maemo.org/news/planet-maemo/</link>
        <lastBuildDate>Sat, 04 Apr 2026 00:04:44 +0000</lastBuildDate>
        <generator>FeedCreator 1.7.6(BH)</generator>
        <language>en</language>
        <managingEditor>planet@maemo.org</managingEditor>
        <item>
            <title>New release of Web Runtime for N900</title>
            <link>http://xizhizhu.blogspot.com/2010/11/new-release-of-web-runtime-for-n900.html</link>
            <description><![CDATA[
Finally, I'm happy to push the latest <a href="http://maemo.org/packages/view/qtwrt/">Web Runtime</a> (v1.1.0) for N900 to the <a href="http://wiki.maemo.org/Extras-devel">extras-devel</a> repository. Please <b><span class="Apple-style-span" style="color: red;">note</span></b> that this release is only tested against PR 1.3. There's no new features implemented compared to the <a href="http://developer.qt.nokia.com/forums/viewthread/307/">previous release</a> back in July, but only bug fixes. Personally, this is one of the last duties for me in the WRT project, and let's see what I would play with in the future ;)<br />
<blockquote><b>What is Web Runtime?</b><br />
It's a development framework with which you can write applications in standard Web technologies, like HTML, CSS, and JavaScript. Also, a bunch of Device APIs are provided to grant you the access to native resources, e.g. file system, sensors, etc., using JavaScript.</blockquote>To <b>install</b> WRT on N900, you should first enable the <a href="http://wiki.maemo.org/Extras-devel">extras-devel</a> repository.<br />
<br />
If you have the previous release installed, you should first uninstall:<br />
sudo gainroot<br />
apt-get purge libwrt-experimental1<br />
<br />
Then install the new release:<br />
sudo gainroot<br />
apt-get install qtwrt<br />
<br />
<a href="http://xizhizhu.blogspot.com/search/label/qtwrt">Have fun</a> and feel free to go to the <a href="http://developer.qt.nokia.com/forums/viewforum/20/">public forum</a> for more questions ;)<span class="net_nemein_favourites">11 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=5d326d72e59c11df9069d58ac4f97b9d7b9d&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/5d326d72e59c11df9069d58ac4f97b9d7b9d/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=5d326d72e59c11df9069d58ac4f97b9d7b9d&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/5d326d72e59c11df9069d58ac4f97b9d7b9d/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Xizhi Zhu &lt;xizhi.zhu@gmail.com&gt;</author>
            <category>feed:a55aba7f8b8bee845720e26917ca5d02</category>
            <pubDate>Mon, 01 Nov 2010 11:34:00 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-5d326d72e59c11df9069d58ac4f97b9d7b9d</guid>
        </item>
        <item>
            <title>Hybrid application using QML and Qt C++</title>
            <link>http://xizhizhu.blogspot.com/2010/10/hybrid-application-using-qml-and-qt-c.html</link>
            <description><![CDATA[
Moved to <a href="http://www.zionsoft.net/2010/10/hybrid-application-qml-qt/">http://www.zionsoft.net/2010/10/hybrid-application-qml-qt/</a><br />
<br />
Though <a href="http://doc.qt.nokia.com/4.7/qdeclarativeintroduction.html">QML</a> provides a nice way to design user interfaces, and JavaScript is employed there to implement the application logic and works pretty nice in many cases, we might still need Qt C++ in some situations (well, at least JavaScript has limited access outside its sandbox).<br />
<br />
<b><span class="Apple-style-span" style="color: blue;">1) integrate QML into Qt C++</span></b><br />
Suppose we have a QML file, named "myqml.qml", like this:<br />
<code class="prettyprint lang-javascript">// this line should be "import QtQuick 1.0" since Qt 4.7.1<br />
import Qt 4.7<br />
<br />
Rectangle {<br />
&nbsp;&nbsp;id: myRectangle<br />
&nbsp;&nbsp;width: 800<br />
&nbsp;&nbsp;height: 480<br />
&nbsp;&nbsp;color: "lightgray"<br />
<br />
&nbsp;&nbsp;Text {<br />
&nbsp;&nbsp;&nbsp;&nbsp;id: myText<br />
&nbsp;&nbsp;&nbsp;&nbsp;text: "I love hybrid application!"<br />
&nbsp;&nbsp;&nbsp;&nbsp;anchors.centerIn: parent<br />
&nbsp;&nbsp;&nbsp;&nbsp;font.pointSize: 28<br />
&nbsp;&nbsp;&nbsp;&nbsp;font.bold: true<br />
&nbsp;&nbsp;}<br />
}</code><br />
<br />
One easy way to integrate is to use the <a href="http://doc.qt.nokia.com/4.7/qdeclarativeview.html">QDeclarativeView</a> class, which provides a widget to display QML files. You just need the following three lines:<br />
<code class="prettyprint lang-cpp">QDeclarativeView view;<br />
view.setSource(QUrl::fromLocalFile("myqml.qml"));<br />
view.show();</code><br />
<br />
However, <i>QDeclarativeView</i> consumes more resources than normal widgets. Fortunately, we can <b><span class="Apple-style-span" style="color: #38761d;"><span class="Apple-style-span" style="font-size: large;">integrate QML into a graphics scene</span></span></b>. The following lines shows the basic usage:<br />
<code class="prettyprint lang-cpp">// provides an environment for instantiating QML components<br />
QDeclarativeEngine engine;<br />
<br />
// encapsulates a QML component definition<br />
QDeclarativeComponent component(&amp;engine, QUrl::fromLocalFile("myqml.qml"));<br />
<br />
// creates the graphics item for QML at the engine's root context<br />
QDeclarativeItem *item = qobject_cast&lt;QDeclarativeItem *&gt;(component.create());<br />
<br />
scene.addItem(item);</code><br />
<br />
Then with the help of the <i>QDeclarativeItem</i> class, you can easily <b><span class="Apple-style-span" style="color: #38761d;">access the properties</span></b> of the QML element, e.g.:<br />
<code class="prettyprint lang-cpp">qDebug() &lt;&lt; item-&gt;property("color").typeName();<br />
item-&gt;setProperty("color", QColor(255, 255, 255));</code><br />
<br />
<b><span class="Apple-style-span" style="color: blue;">2) exposing Qt C++ objects to QML</span></b><br />
You can also <b><span class="Apple-style-span" style="color: #38761d;">expose native Qt C++ objects to QML</span></b> through <i>QDeclarativeContext</i>:<br />
<code class="prettyprint lang-cpp">QDeclarativeContext *context = engine-&gt;rootContext();<br />
context-&gt;setContextProperty("textFromQt", QString("I love hybrid application!"));</code><br />
<br />
Then in QML, you can have e.g. the following line to access them:<br />
<code class="prettyprint lang-javascript">text: textFromQt</code><br />
<br />
You can also use <i>QDeclarativePropertyMap</i> to manage the exposed properties:<br />
<code class="prettyprint lang-cpp">QDeclarativePropertyMap map;<br />
map.insert("key1", "value1");<br />
map.insert("key2", "value2");<br />
context-&gt;setContextProperty("map", &amp;map);</code><br />
<br />
<blockquote>In a QML engine, there could be a couple of contexts, forming a tree structure. The child contexts inherit properties in the parent context. By default, there is only one root context, but you can always add more to give finer control of the exposed data, i.e. different QDeclarativeComponent inside the same context have the same exposed data set.</blockquote><br />
To <b><span class="Apple-style-span" style="color: #38761d;">expose a self-defined object</span></b>, we can use the following code:<br />
<code class="prettyprint lang-cpp">// define a class with properties<br />
class MyObject: public QObject<br />
{<br />
&nbsp;&nbsp;Q_OBJECT<br />
<br />
&nbsp;&nbsp;// the NOTIFY signal is needed to inform about changes<br />
&nbsp;&nbsp;// all properties will be exposed to QML<br />
&nbsp;&nbsp;Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)<br />
public:<br />
&nbsp;&nbsp;MyObject(QObject *parent = 0) : QObject(parent), m_text("I love hybrid application!") {}<br />
<br />
&nbsp;&nbsp;QString text() const { return m_text; }<br />
&nbsp;&nbsp;void setText(QString &amp;text)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;m_text = text;<br />
&nbsp;&nbsp;&nbsp;&nbsp;emit textChanged();<br />
&nbsp;&nbsp;}<br />
<br />
signals:<br />
&nbsp;&nbsp;void textChanged();<br />
<br />
private:<br />
&nbsp;&nbsp;QString m_text;<br />
};<br />
<br />
// then just expose it so QML can access it through name "myObject"<br />
engine-&gt;rootContext()-&gt;setContextProperty("myObject", new MyObject());</code><br />
<br />
Moreover, we can <b><span class="Apple-style-span" style="font-size: large;"><span class="Apple-style-span" style="color: #38761d;">create new QML types</span></span></b>:<br />
<code class="prettyprint lang-cpp">// define the new type<br />
class MyType : public QDeclarativeItem<br />
{<br />
&nbsp;&nbsp;Q_OBJECT<br />
<br />
public:<br />
&nbsp;&nbsp;MyType(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;setFlag(QGraphicsItem::ItemHasNoContents, false);<br />
&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;QPen pen(QColor(100, 100, 100), 2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;painter->setPen(pen);<br />
&nbsp;&nbsp;&nbsp;&nbsp;painter->drawLine(0, 100, 100, 100);<br />
&nbsp;&nbsp;}<br />
};<br />
<br />
// then register to expose it<br />
qmlRegisterType&lt;mychart&gt;("com.blogspot.xizhizhu.mytype", 1, 0, "MyType");</code><br />
<br />
In QML, you can use it like this:<br />
<code class="prettyprint lang-javascript">import com.blogspot.xizhizhu.mytype 1.0<br />
<br />
MyChart {<br />
&nbsp;id: myChart<br />
&nbsp;width: 100<br />
&nbsp;height: 200<br />
}</code><br />
<br />
Now let's jump to <b><span class="Apple-style-span" style="color: #38761d;">invoke a Qt C++ function from QML</span></b>. Basically, QML can invoke slots and functions declared with <i>Q_INVOKABLE</i>. Suppose we have the following function in MyObject:<br />
<code class="prettyprint lang-cpp">Q_INVOKABLE void showMessage()<br />
{<br />
&nbsp;&nbsp;QMessageBox::information(NULL, "My Test", "Invoking a native function ;)");<br />
}</code><br />
<br />
Then you can invoke it in QML:<br />
<code class="prettyprint lang-javascript">myObject.showMessage();</code><br />
<br />
<b><span class="Apple-style-span" style="color: blue;">3) write plugins as QML extension</span></b><br />
The benefits for using plugins as QML extensions are similar to using shared libraries, and it can be easily achieved with the help of <i>QDeclarativeExtensionPlugin</i>. Let's reuse the MyType class defined in the previous section. First, we need to <b>create a plugin</b>:<br />
<code class="prettyprint lang-cpp">class MyPlugin : public QDeclarativeExtensionPlugin<br />
{<br />
&nbsp;&nbsp;Q_OBJECT<br />
public:<br />
&nbsp;&nbsp;void registerTypes(const char *uri)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;qmlRegisterType&lt;MyType&gt;(uri, 1, 0, "MyType");<br />
&nbsp;&nbsp;}<br />
};<br />
<br />
Q_EXPORT_PLUGIN2(myPlugin, MyPlugin);</code><br />
<br />
Then <b>create a file named "qmldir"</b> to define which plugin to load from where (suppose the plugin is called "myplugin):<br />
<code class="prettyprint lang-javascript">plugin myplugin /path/to/plugin</code><br />
<br />
Now we can use <i>qmlviewer</i> to launch the QML file:<br />
<code class="prettyprint lang-javascript">// no need to import now<br />
MyChart {<br />
&nbsp;id: myChart<br />
&nbsp;width: 100<br />
&nbsp;height: 200<br />
}</code><br />
<br />
<b><span class="Apple-style-span" style="color: blue;">4) summary</span></b><br />
<li>Use <i>QDeclarativeView</i> or <i>QDeclarativeComponent</i> to integrate a QML file into native Qt C++.</li><li>Qt C++ can access the properties of QML elements through <i>QDeclarativeItem</i>.</li><li>Expose native objects to QML through <i>QDeclarativeContext</i>.</li><li>New QML types can be exported through <i>qmlRegisterType</i>.</li><li>The properties of native objects are exported as properties, and the slots or functions declared with Q_INVOKABLE can be invoked in QML.</li><li>Create plugins for extension using <i>QDeclarativeExtensionPlugin</i>.</li><span class="net_nemein_favourites">9 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=3b628316e2b411df964959e3dbe21c2e1c2e&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/3b628316e2b411df964959e3dbe21c2e1c2e/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=3b628316e2b411df964959e3dbe21c2e1c2e&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/3b628316e2b411df964959e3dbe21c2e1c2e/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Xizhi Zhu &lt;xizhi.zhu@gmail.com&gt;</author>
            <category>feed:a55aba7f8b8bee845720e26917ca5d02</category>
            <pubDate>Thu, 28 Oct 2010 19:36:00 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-3b628316e2b411df964959e3dbe21c2e1c2e</guid>
        </item>
        <item>
            <title>Unofficial Qt Web Runtime tutorial 2: Menu API</title>
            <link>http://xizhizhu.blogspot.com/2010/09/unofficial-qt-web-runtime-tutorial-2.html</link>
            <description><![CDATA[
If there is no API, Qt WRT is merely nothing but a naive web browser. Then what APIs are supported other than standard HTML and JavaScript now? You can first get a list of features already supported, or to be supported in the near future <a href="http://bugs.meego.com/showdependencytree.cgi?id=2772&amp;hide_resolved=0">here</a>.<br />
<br />
As a summary, we have already supported the APIs of menus, <a href="http://www.w3.org/TR/widgets-apis/">widget object</a>, <a href="http://www.w3.org/TR/widgets-uri/">URI schemes</a>, <a href="http://trac.webkit.org/wiki/WebInspector">web inspector</a>, console log, some Device APIs, as well as some HTML 5 features and standard JavaScript from Qt WebKit. Let's start with the menu API.<br />
<br />
<b><span class="Apple-style-span" style="color: blue;">1 view menu</span></b><br />
You can create <b>the menu items to the chrome's menu bar</b> (we call it view menu) with the following JavaScript code:<br />
<code class="prettyprint lang-javascript">var menuItem = new nokia.device.MenuItem("Menu item", changeTitle);<br />
nokia.device.menu.addMenuItem(menuItem);<br />
function changeTitle()<br />
{                                            <br />
&nbsp;&nbsp;nokia.device.menu.title = "New title";                          <br />
}</code><br />
<br />
Here, you have created a menu item named "Menu item" and added it to the menu bar. When it's triggered, the function changeTitle() will be called to set the menu's title to "New title".<br />
<br />
<b>Note</b> that since on the device the menu's title is also the same as the window's title, it actually changes the window's title too.<br />
<br />
<b><span class="Apple-style-span" style="color: blue;">2 context menu</span></b><br />
The <b>context menu</b> can be created with the following piece of code:<br />
<code class="prettyprint lang-javascript">var contextMenu = new nokia.device.ContextMenu("contextMenuArea");<br />
var changeTitleItem = new nokia.device.MenuItem("Change Title");<br />
changeTitleItem.onselect = changeTitle;<br />
contextMenu.addMenuItem(changeTitleItem);</code><br />
<br />
Here, a context menu is created and an item named "Change Title" is added to the menu. When you long tap on the HTML element with id "contextMenuArea", this context menu will pop up. Then if you select the "Change Title" item, the changeTitle() function will be called.<br />
<br />
<blockquote>Of course, only the widgets in the <i>windowed</i> or <i>fullscreen</i> mode could have <b>context menus</b>; and only the widgets in the <i>windowed</i> mode can have <b>view menus</b>.</blockquote><br />
<b>Note</b> that there's a known bug (already fixed for the next release) that if you long tap on the area where no context menu is defined, an empty context menu is popped-up.<br />
<br />
<b><span class="Apple-style-span" style="color: blue;">3 sample</span></b><br />
Only the HTML file this time ;)<br />
<code class="prettyprint lang-html">&lt;html&gt;<br />
&lt;header&gt;<br />
&nbsp;&nbsp;&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;<br />
&nbsp;&nbsp;&lt;title&gt;Menu sample&lt;/title&gt;<br />
&nbsp;&nbsp;&lt;script type="text/javascript"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;function changeTitle()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (nokia.device.menu.title == "Title 1")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nokia.device.menu.title = "Title 2";<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nokia.device.menu.title = "Title 1";<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;function init()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var menuItem = new nokia.device.MenuItem("item", changeTitle);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nokia.device.menu.addMenuItem(menuItem);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var contextMenu = new nokia.device.ContextMenu("contextMenuArea");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contextMenu.addMenuItem(menuItem);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&lt;/script&gt;<br />
&lt;/header&gt;<br />
&lt;body onload="init()"&gt;<br />
&nbsp;&nbsp;&lt;div id="contextMenuArea"&gt;There is a context menu.&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code><br />
<br />
As you can see, one menu item can be added to multiple menus, exactly the same as native Qt apps. Here goes some screenshots:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://media.share.ovi.com/m1/s/2428/c180ec06bf9f4804850c76e13ff5be20.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2428/c180ec06bf9f4804850c76e13ff5be20.jpg" width="320" /></a>&nbsp;<a href="http://media.share.ovi.com/m1/s/2428/d13371e97dfc4657a55d8887edfe6459.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2428/d13371e97dfc4657a55d8887edfe6459.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://media.share.ovi.com/m1/s/2428/fa9df2d3f04e4b5196488145bdff67e0.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2428/fa9df2d3f04e4b5196488145bdff67e0.jpg" width="320" /></a>&nbsp;<a href="http://media.share.ovi.com/m1/s/2431/c099edca2f2247fd832c03ed7b83ca49.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2431/c099edca2f2247fd832c03ed7b83ca49.jpg" width="320" /></a></div><br />
The first one shows the simple sample when launched. The second and third one show the view menu and the context menu, respectively, while the last one shows that the title has been updated after you tap on the menu. More screenshots can be found <a href="http://share.ovi.com/album/xizhizhu.QtWebRuntim">here</a>, while the sample code is available <a href="http://gitorious.org/xizzhu-samples/qtwrt-menu-sample">here</a>.<span class="net_nemein_favourites">12 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=e084175ebd1311df9690e7c4721aaae0aae0&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/e084175ebd1311df9690e7c4721aaae0aae0/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=e084175ebd1311df9690e7c4721aaae0aae0&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/e084175ebd1311df9690e7c4721aaae0aae0/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Xizhi Zhu &lt;xizhi.zhu@gmail.com&gt;</author>
            <category>feed:a55aba7f8b8bee845720e26917ca5d02</category>
            <pubDate>Fri, 10 Sep 2010 22:23:00 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-e084175ebd1311df9690e7c4721aaae0aae0</guid>
        </item>
        <item>
            <title>Unofficial QtWRT tutorial 1: Hello, view modes!</title>
            <link>http://xizhizhu.blogspot.com/2010/08/unofficial-qtwrt-tutorial-1-hello-view.html</link>
            <description><![CDATA[
Almost one month ago, we <a href="http://labs.trolltech.com/blogs/2010/07/19/the-qt-web-runtime-journey-begins/">announced</a> Qt Web Runtime, and <a href="http://download.qt.nokia.com/qtwrt/">released</a> some snapshot for N900. Basically, QtWRT is a framework, using which you can write "native" application with standard web technology, e.g. HTML, CSS, and JavaScript. As a good starting point, you should take a look at <a href="http://dkothari.blogspot.com/2010/08/qt-web-runtime-for-n900.html">this article</a>.<br />
<br />
<b>Note that we're still working on it, and it's now just in the technology preview state ;)</b><br />
<br />
<b><span class="Apple-style-span" style="color: blue;">1 install QtWRT</span></b><br />
You should <a href="http://wiki.maemo.org/Extras-devel">enable the extras-devel repository</a> on your Rover and install the <b><i>qtwrt-experimental</i></b> package from there. Then, you can find in your Application Manager that Qt Web Runtime Technology Preview for N900 installed.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://media.share.ovi.com/m1/s/2371/612d8bc2545744dca9ccbf497309bbc8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2371/612d8bc2545744dca9ccbf497309bbc8.jpg" width="320" /></a></div><br />
<b><span class="Apple-style-span" style="color: blue;">2 config.xml</span></b><br />
To write your own web applications, besides the normal HTML pages, you also need a <b>config.xml<i></i></b> file to define e.g. the starting file, icon, features you need (i.e. access to Device APIs), as well as author's information, etc. More details and default values are defined <a href="http://www.w3.org/TR/widgets/">here</a>.<br />
<br />
The following piece shows a minimum sample:<br />
<code class="prettyprint lang-xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;widget xmlns = "http://www.w3.org/ns/widgets"&gt;<br />
&lt;/widget&gt;</code><br />
<br />
You can also define the name and icon (only PNG files supported) of the web app in config.xml:<br />
<code class="prettyprint lang-xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;widget xmlns = "http://www.w3.org/ns/widgets"&gt;<br />
&nbsp;&nbsp;&lt;name&gt;A sample web app&lt;/name&gt;<br />
&nbsp;&nbsp;&lt;icon src="app_icon.png" /&gt;<br />
&lt;/widget&gt;</code><br />
The name and icon will be appeared in the Application Grid or the Desktop menu --&gt; Add widget based on the view mode the web app supports (see below).<br />
<br />
<b><span class="Apple-style-span" style="color: blue;">3 view modes</span></b><br />
View modes define the visual presentation of web applications. The W3C spec has <a href="http://www.w3.org/TR/view-mode/">defined</a> five different view modes, but we only support three of them in this snapshot:<br />
<b>windowed</b> - The default view mode. You can find / launch web apps in this mode from the Application Grid. It also supports the native chromes and user-defined menus.<br />
<b>fullscreen</b> - It can also be found / launched from the Application Grid. No need to say what is full screen, right ;)<br />
<b>minimized</b> - It equals to the native widgets on the Home Screen.<br />
<br />
The following piece defines the view modes in config.xml:<br />
<code class="prettyprint lang-xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;widget xmlns = "http://www.w3.org/ns/widgets"<br />
&nbsp;&nbsp;&nbsp;&nbsp;viewmodes = "someviewmode fullscreen minimized" &gt;<br />
&lt;/widget&gt;</code><br />
The unknown view mode "someviewmode" is ignored. It supports both "fullscreen" and "minimized" mode in this case. If no supported view mode is defined, "windowed" mode is used.<br />
<br />
You can get the current view mode through the <b>widget.viewMode</b> interface in JavaScript.<br />
<br />
Also, the transfer among different view modes is supported, with the exception from windowed / fullscreen to minimized, e.g.:<br />
<code class="prettyprint lang-html">&lt;a href="javascript:widget.viewMode='windowed'"&gt;Go to windowed mode&lt;/a&gt;</code><br />
<br />
With the following code, you can handle the view mode change event in the viewModeChanged function:<br />
<code class="prettyprint lang-javascript">widget.onviewmodechange = viewModeChanged;<br />
function viewModeChanged(mode)<br />
{<br />
&nbsp;&nbsp;if (mode == "windowed") {<br />
&nbsp;&nbsp;&nbsp;&nbsp;// going to windowed mode<br />
&nbsp;&nbsp;} else if (mode == "minimized") {<br />
&nbsp;&nbsp;&nbsp;&nbsp;// going to minimized mode<br />
&nbsp;&nbsp;} else if (mode == "fullscreen") {<br />
&nbsp;&nbsp;&nbsp;&nbsp;// going to full screen mode<br />
&nbsp;&nbsp;}<br />
}</code><br />
<br />
<b><span class="Apple-style-span" style="color: blue;">4 package your application and install it</span></b><br />
Well, I just assume you have enough knowledge to write whatever HTML page you like, and have renamed it to <b><i>index.htm</i></b> (the default starting file name).<br />
<br />
Now just zip all your HTML files together with the config.xml file. <b>Note</b> that the config.xml file should be at the top level of the zip, and the name is case sensitive.<br />
<br />
Then please rename it to *.wgt and copy it to your Rover. To make it like a native application, you can install it from the File Manager, and you can find your installed web applications in Application Manager!<br />
<br />
<blockquote>Eh, I'm talking about some details during the installation here. You can skip this if not interested.<br />
<br />
When you tap on the wgt file in File Manager, <i>widgetinstaller</i> is launched. It does some sanity checking of it, e.g. whether it's a valid zip file, if the config.xml is valid, etc., then convert it to a Debian file, and use the Application Manager to install the generated Debian file.<br />
<br />
If you are interested in the generated Debian file, you can use the "--no-install" option of the widgetinstaller to have it copied to the current directory.</blockquote><br />
<b><span class="Apple-style-span" style="color: blue;">5 a sample</span></b><br />
First, let's write the <b>config.xml</b> file.<br />
<code class="prettyprint lang-xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;widget xmlns="http://www.w3.org/ns/widgets"<br />
&nbsp;&nbsp;&nbsp;&nbsp;id="http://xizhizhu.blogspot.com/qtwrt/view-modes-sample"<br />
&nbsp;&nbsp;&nbsp;&nbsp;viewmodes="minimized fullscreen windowed"&gt;<br />
&nbsp;&nbsp;&lt;name&gt;View Modes Sample&lt;/name&gt;<br />
&nbsp;&nbsp;&lt;description&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Well, it shows how the view modes work.<br />
&nbsp;&nbsp;&lt;/description&gt;<br />
&nbsp;&nbsp;&lt;author href="http://xizhizhu.blogspot.com/" email="xizhi.zhu@gmail.com"&gt;Xizhi Zhu&lt;/author&gt;<br />
&nbsp;&nbsp;&lt;license&gt;In the public domain without any warranty.&lt;/license&gt;<br />
&lt;/widget&gt;</code><br />
<br />
Then the HTML file.<br />
<code class="prettyprint lang-html">&lt;html&gt;<br />
&lt;header&gt;<br />
&nbsp;&nbsp;&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;<br />
&nbsp;&nbsp;&lt;title&gt;View Modes&lt;/title&gt;<br />
&nbsp;&nbsp;&lt;script type="text/javascript"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;function init()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output = document.getElementById("viewmode");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output.innerHTML = widget.viewMode;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;widget.onviewmodechange = changeViewMode;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;function changeViewMode(mode)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output.innerHTML = widget.viewMode;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&lt;/script&gt;<br />
&lt;/header&gt;<br />
<br />
&lt;body onload="init()"&gt;<br />
&nbsp;&nbsp;&lt;div id="viewmode"&gt;&lt;/div&gt;&lt;br /&gt;<br />
&nbsp;&nbsp;&lt;a href="javascript:widget.viewMode='minimized'"&gt;minimized&lt;/a&gt;&lt;br /&gt;<br />
&nbsp;&nbsp;&lt;a href="javascript:widget.viewMode='windowed'"&gt;windowed&lt;/a&gt;&lt;br /&gt;<br />
&nbsp;&nbsp;&lt;a href="javascript:widget.viewMode='fullscreen'"&gt;fullscreen&lt;/a&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code><br />
<br />
Now let's zip the file, send it to N900 and install it from the File Manager. You can find it installed in the Application Manager and already launched in the home screen.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://media.share.ovi.com/m1/s/2371/e60a8041c7d84c70909e0be9b48c379f.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2371/e60a8041c7d84c70909e0be9b48c379f.jpg" width="320" /></a><a href="http://media.share.ovi.com/m1/s/2371/67a55e14988b4ed290d4e21943addb79.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2371/67a55e14988b4ed290d4e21943addb79.jpg" width="320" /></a></div><br />
You may ask, why the last line of "fullscreen" is not shown there? Well, that's due to the <b>fixed size</b> in the <i>minimized</i> mode, 312x82. Also, in the <i>minimized</i> mode, you can't actually interact with it, but only tap on it and open the <i>windowed</i> or <i>fullscreen</i> mode if supported. In the <i>minimized</i> mode, it's <b>the same as native widgets</b> that you can move it around, close it and add it back, as well as the transparent background by default.<br />
<br />
Then you can tap the links to toggle between <i>windowed</i> and <i>fullscreen</i> mode. And for sure you'll find another "limitation" that you can't go back to <i>minimized</i> mode from the link. The only way is to close the window. Well, that's exactly what is expected.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://media.share.ovi.com/m1/s/2371/90ca8dbb537d4053afb2bcd781a37922.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2371/90ca8dbb537d4053afb2bcd781a37922.jpg" width="320" /></a><a href="http://media.share.ovi.com/m1/s/2371/7b05ca2788c349b280a02733b392cc1b.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://media.share.ovi.com/m1/s/2371/7b05ca2788c349b280a02733b392cc1b.jpg" width="320" /></a></div><br />
<br />
Another thing is, in the <i>fullscreen</i> mode, it automatically shows the "go back to windowed" button if <i>windowed</i> mode is supported, otherwise the "close" button. Emm, the same as the browser, right?<br />
<br />
<br />
<b>Updated on 19.8.2010</b><br />
Screenshots added into the posts ;)<span class="net_nemein_favourites">10 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=2048e12aab6d11df91ae41bb542a30b130b1&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/2048e12aab6d11df91ae41bb542a30b130b1/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=2048e12aab6d11df91ae41bb542a30b130b1&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/2048e12aab6d11df91ae41bb542a30b130b1/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Xizhi Zhu &lt;xizhi.zhu@gmail.com&gt;</author>
            <category>feed:a55aba7f8b8bee845720e26917ca5d02</category>
            <pubDate>Wed, 18 Aug 2010 23:07:00 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-2048e12aab6d11df91ae41bb542a30b130b1</guid>
        </item>
        <item>
            <title>JavaScript benchmarking on N900 PR1.2</title>
            <link>http://xizhizhu.blogspot.com/2010/05/javascript-benchmarking-on-n900-pr12.html</link>
            <description><![CDATA[
Two months earlier, I did my <a href="http://xizhizhu.blogspot.com/2010/03/javascript-benchmarking-on-n900-and-my.html">JavaScript benchmarking</a> on N900 PR1.1, and compare it with other platforms. Now, as N900 PR1.2 got released, Opera has <a href="http://labs.opera.com/news/2010/05/11/">released</a> a preview for Maemo, and Chrome is ported to N900 by <a href="http://jacekowski.org/maemo/index.html">Jacekowski</a>, I did another round of benchmarking.<br />
<br />
<table><tr><td></td><td><b>V8</b></td><td><b>SunSpider</b></td><td><b>Peacekeeper</b></td></tr>
<tr><td><b>MicroB (default browser)</b></td><td>21.2</td><td>35.12</td><td>128</td></tr>
<tr><td><b>FireFox</b></td><td>21.4</td><td>15.84</td><td>141</td></tr>
<tr><td><b>Opera</b></td><td>49.5</td><td>24.41</td><td>119</td></tr>
<tr><td><b>Qt 4.6.2</b></td><td>105</td><td>12.04</td><td>238</td></tr>
<tr><td><b><a href="http://gitorious.org/+qtwebkit-packagers/webkit/qtwebkit-maemo5">QtWebKit 2.0</a></b></td><td>104</td><td>9.36</td><td>286</td></tr>
<tr><td><b>Chrome</b></td><td>113</td><td>8.84</td><td>344</td></tr>
</table>For V8 and Peacemaker, the higher the score, the better performance it has. For Sunspider, it's the lower the better.<br />
<br />
Chrome is really fast as a result of its excellent V8 JavaScript engine and frequent release cycle.<br />
<br />
Qt 4.6.2 is still quite good, especially considering the fact that the WebKit integrated is quite old. Note that QtWebKit will be released <a href="http://labs.trolltech.com/blogs/2010/03/03/qtwebkit-releases/">separately</a> from Qt, meaning we could enjoy more about the latest WebKit technology then.<br />
<br />
However, both Opera and FireFox (MicroB uses FireFox's Gecko JavaScript engine) have quite a long way to go. Moreover, when running V8 and Peacekeeper, both MicroB and FireFox complained about unresponsive JavaScript.<span class="net_nemein_favourites">0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=1f9eb6faab6d11df91ae41bb542a30b130b1&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/1f9eb6faab6d11df91ae41bb542a30b130b1/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=1f9eb6faab6d11df91ae41bb542a30b130b1&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/1f9eb6faab6d11df91ae41bb542a30b130b1/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Xizhi Zhu &lt;xizhi.zhu@gmail.com&gt;</author>
            <category>feed:a55aba7f8b8bee845720e26917ca5d02</category>
            <pubDate>Sun, 30 May 2010 14:40:00 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-1f9eb6faab6d11df91ae41bb542a30b130b1</guid>
        </item>
        <item>
            <title>JavaScript benchmarking on N900 and my laptop</title>
            <link>http://xizhizhu.blogspot.com/2010/03/javascript-benchmarking-on-n900-and-my.html</link>
            <description><![CDATA[
I just ran some JavaScript benchmark tests of <a href="http://v8.googlecode.com/svn/data/benchmarks/v5/run.html">V8 version 5</a>, <a href="http://www2.webkit.org/perf/sunspider-0.9.1/sunspider-0.9.1/driver.html">SunSpider v0.9.1</a> and <a href="http://service.futuremark.com/peacekeeper/run.action">Peacekeeper</a> on my laptop. My laptop is HP EliteBook 6930p, which has Intel Core 2 Duo CPU P8600 @ 2.40GHz, 4 GB RAM, running KUbuntu 9.10 with kernel 2.6.31-20-generic. Also, I ran it on my N900 PR1.1 with Qt 4.6.2, and collected some results for <a href="http://arstechnica.com/apple/reviews/2009/06/iphone-3g-s-review.ars/6">iPhone 3GS</a>, <a href="http://www.gubatron.com/blog/2010/01/10/droid-vs-nexus-1-sunspider-javascript-benchmark-showdown/">Droid and Nexus One</a>, and <a href="http://mobile.zol.com.cn/174/1744080.html">HTC Desire</a>.<br />
<br />
The following scores are from <strong>V8</strong>, the higher the better.<br />
FireFox for Ubuntu 3.5.8 - 248<br />
Qt 4.6.2 – 910<br />
Chrome 5.0.307.11 Beta – 4155<br />
QtWebKit 2.0 – 2816<br />
N900 - 105<br />
iPhone 3GS - no results<br />
Droid - 39.5<br />
Nexus One - 63.5<br />
HTC Desire - 66.1<br />
<br />
Then I found some <a href="http://arstechnica.com/apple/reviews/2009/06/iphone-3g-s-review.ars/6">results</a> of iPhone 3GS for V8 version 3:<br />
N900 - 103<br />
iPhone 3GS - 53<br />
<br />
The following scores are from <strong>SunSpider</strong>, the lower the better.<br />
FireFox for Ubuntu 3.5.8 – 2484.7<br />
Qt 4.6.2 – 1136.0<br />
Chrome 5.0.307.11 Beta – 462.1<br />
QtWebKit 2.0 – 635.6<br />
N900 - 12.5<br />
iPhone 3GS - 16.7<br />
Droid - 34.2<br />
Nexus One - 14.7<br />
HTC Desire - 12.02<br />
<br />
The following scores are from <strong>Peacekeeper</strong>, the higher the better.<br />
FireFox for Ubuntu 3.5.8 – 1510<br />
Qt 4.6.2 – 3261<br />
Chrome 5.0.307.11 Beta – 4324<br />
QtWebKit 2.0 – 4288<br />
N900 - 244<br />
<br />
Chrome’s V8 engine is <span style="color: red;"><strong>really fast</strong></span>, and WebKit still has a long way to go!<br />
<br />
Also, N900 performs <span style="color: red;"><strong>much better</strong></span> than iPhone 3GS, Droid and Nexus. Considering HTC Desire, N900 wins easily on V8, but lost a little on SunSpider. However, if you consider MicroB, the default browser on N900, it’s a <b>disaster</b> due to the slow engine of Gecko and N900 even used a pretty old version.<br />
<br />
Then the <a href="http://acid3.acidtests.org/">ACID3</a> test.<br />
FireFox for Ubuntu 3.5.8 – 93<br />
Qt 4.6.2 – 100<br />
Chrome 5.0.307.11 Beta – 100<br />
QtWebKit 2.0 – 100<br />
<br />
<br />
* The test for QtWebKit 2.0 is done with the revision number of 56441.<span class="net_nemein_favourites">0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=1e5748acab6d11df91ae41bb542a30b130b1&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/1e5748acab6d11df91ae41bb542a30b130b1/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=1e5748acab6d11df91ae41bb542a30b130b1&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/1e5748acab6d11df91ae41bb542a30b130b1/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Xizhi Zhu &lt;xizhi.zhu@gmail.com&gt;</author>
            <category>feed:a55aba7f8b8bee845720e26917ca5d02</category>
            <pubDate>Sat, 20 Mar 2010 15:11:00 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-1e5748acab6d11df91ae41bb542a30b130b1</guid>
        </item>
    </channel>
</rss>
