Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Porting WRT widgets to QML
This article introduces the basic information and steps needed to port a Symbian Web Runtime widget to Qt Quick.
Why should you port a WRT widget to QML?
QML offers multiple benefits over classical WRT widgets, including:
- improved performances: QML applications run faster than WRT widgets, meaning smoother animations and improved user experience
- Qt extensibility: if QML doesn't offer all the functionality needed in an application, it can be easily extended by writing the needed functionalities in Qt, and accessing those by the QML layer
- Cross platform: being part of Qt, QML allows to create UIs and applications that can be deployed on multiple operating systems, including Symbian, MeeGo, Windows, Linux, OSX
Where to start?
A first introduction to the differences between the Web and QML environments is available in the article: Introduction to QML for Web developers. The topics covered by that article include:
- Standard and custom UI elements
- Positioning of UI elements
- UI manipulation
- UI styling
Knowledge of the topics covered in that article is needed to fully understand the differences and the techniques to successfully port an application from the WRT world to QML.
This article will focus on the additional steps required to port WRT-specific functionalities to the QML environment.
The WRT environment supports three different kinds of focus management, settable by a WRT widget via the widget setNavigationType method:
- cursor based: based on the mouse cursor, with the cursor moved by the user using the navigation pad
- tabbed based: no cursor is shown, the user moves the focus using the navigation pad
Saving local data
Managing the device orientation
Qt Quick does not currently allow to lock the device orientation directly via QML, so a line of Qt code is needed. Specifically, it is necessary to call the setOrientation method of the QmlApplicationViewer instance:
WRT has an inbuilt support for adding and managing the menu items associated to the device softkeys.
Audio and Video
In WRT widgets, audio and video playback is possible mainly through the usage of embedded Flash Lite movies, as in the case of the On demand Web TV – have your favorite channels with you.
QML does not offer an inbuilt support for audio and video, but the Multimedia QML plugin from Qt Mobility 1.1 brings this functionality to the QML enviroment. Thanks to this plugin, audio and video can be used in QML applications with plain declarative syntax.
While QML has no inbuilt APIs to access low-level functionalities, there are solutions that include:
- Qt Mobility QML plugins: through a set of plugins, the Qt Mobility project adds new functionalities to the QML language.
- Extending QML with C++ code: more information is available here
The Qt Mobility QML Plugins
This sections shows how functionalities based on Platform Services can be ported to QML applications with the help of Qt Mobility QML plugins.
|Platform Services API||QML API||Notes|
|Calendar API||Organizer plugin from Qt Mobility 1.2|
|Contacts API||Contacts plugin from Qt Mobility 1.2|
|LandMarks API||Location plugin from Qt Mobility 1.2|
|Location API||Location plugin from Qt Mobility 1.2|
|Media Management API||Gallery plugin from Qt Mobility 1.1|
|Messaging API||Messaging plugin from Qt Mobility 1.1|
|Sensors API||Sensors plugin from Qt Mobility 1.2|
|System Information API||System Information API from Qt Mobility 1.2||Check out the available [QML Classes|