MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Developing plain Qt and Qt WebKit applications for Harmattan

This section provides useful information on developing new applications for the MeeGo 1.2 Harmattan platform or porting existing applications that use plain Qt or QtWebkit.

Note: On the Harmattan platform, it is recommended to use the Qt Quick Components, OpenGL ES (OpenGL for Embedded Systems), MeeGo Touch, or QtWebkit framework. Using plain Qt sets some limitations for your Harmattan application. For more information, see section QWidget, QGraphicsView, and plain Qt Quick in the Application development framework.

Using the virtual keyboard in your application

In plain Qt and QtWebKit applications, the virtual keyboard may not be automatically hidden when it is unfocused.

Using the virtual keyboard in plain QML applications

The problem appears in applications that use the TextEdit and TextInput elements. To solve the issue, do either of the following:

  • The recommended solution is to use Qt Quick Components and the TextArea and TextField elements instead. For more information, see the Qt Quick Components documentation in MeeGo 1.2 Harmattan API reference.
  • If you do not use Qt Quick Components, you must call TextEdit.closeSoftwareInputPanel before setting the focus to false.

Using the virtual keyboard in QtWebKit applications

To solve the issue, do the following:

1. Add the following event filter to the affected view instance:
class EventFilter : public QObject
    bool eventFilter(QObject *obj, QEvent *event) {
        QInputContext *ic = qApp->inputContext();
        if (ic) {
            if (ic->focusWidget() == 0 && prevFocusWidget) {
                QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
            } else if (prevFocusWidget == 0 && ic->focusWidget()) {
                QEvent openSIPEvent(QEvent::RequestSoftwareInputPanel);
            prevFocusWidget = ic->focusWidget();
        return QObject::eventFilter(obj,event);

    QWidget *prevFocusWidget;
2. Install the filter on a QGraphicsView or (in QML) on a QDeclarativeView instance:
EventFilter ef;

Rotating your application

Plain Qt and QtWebKit applications cannot handle orientation correctly on all platforms if they use only the standard Qt APIs. For more instructions on controlling rotation, see Controlling rotation.

Running plain Qt OpenGL applications

Make sure that you use the MeeGo graphics system in your application. The graphics system ensures that the GL context of your application is dropped when it is in the background.

Limitations related to QWidgets

Do not use QWidget-based UI elements. Instead, take advantage of Qt Quick Components, which are ideally suitable for mobile touch screen devices and they match the Harmattan native look and feel. For more information, see Application development framework.

QML Viewer

The QML Viewer is not available on the Harmattan device. Instead, use the Qt SDK and create a project using the Qt Quick Application template. The template allows you to test your QML applications just as easily, and you can run the applications on the device and in Qt Simulator. It is also easy to extend the template into an actual application.