Qt Reference Documentation

Maemo 5 Window States Example


The Maemo 5 Window States example shows how to handle different states of top-level widgets with Qt on Maemo 5.

Since Maemo 5 is touch-based, it does not have a mouse cursor. In order to indicate to the user that an application is busy, a special attribute needs to be set on a top-level widget, which causes the Maemo 5 window manager to display a "busy" indicator in the application's title bar.

     void toggleBusy(int checkState)
         setAttribute(Qt::WA_Maemo5ShowProgressIndicator, checkState == Qt::Checked);

The toggleBusy() slot activates or deactivates the Qt::WA_Maemo5ShowProgressIndicator window attribute on the top-level example widget according to the checkState parameter.

     void showExpose()
         QDBusConnection c = QDBusConnection::sessionBus();
         QDBusMessage m = QDBusMessage::createSignal("/", "com.nokia.hildon_desktop", "exit_app_view");

To programmatically show an Exposee of all running applications on the device, an application can send a request via a D-Bus signal on the D-Bus session bus. The D-Bus signal must emit the function "exit_app_view" on the interface "com.nokia.hildon_desktop" on the root object path "/".

     void toggleFullScreen()
         bool isFullScreen = windowState() & Qt::WindowFullScreen;
         if (isFullScreen)

The Maemo 5 window manager shows all top-level widgets maximized by default. In order to show a top-level widget full-screen, call QWidget::showFullScreen(). To exit full-screen, call QWidget::showNormal(). Whether a top-level widget is currently full screen can be queried by testing whether the QWidget::windowState() contains Qt::WindowFullScreen.

When to exit full-screen mode is up to the application. The Maemo 5 image viewer exits full screen when the user clicks on the currently displayed image. Other applications show a semi-transparent button that, when clicked, cause them to exit full-screen mode. This example contains a class FullScreenExitButton in a separate single header file that can be copied and used in any project. This shows a semi-transparent full-screen exit button in the lower-right corner of your application.

         new FullScreenExitButton(this);

FullScreenExitButton can be instantiated on any top-level widget. Once the top-level widget enters full-screen, it becomes visible. If the top-level widget leaves full-screen mode, it automatically hides itself. When clicked by the user, it calls QWidget::showNormal() on its top-level widget.

 #include <X11/Xlib.h>
 #include <X11/Xatom.h>

In order to set other window states that are not directly supported by Qt, X11 can be used directly. These two headers are required to interact with X11.

     void toggleDisturb(int checkState)
         Atom atom = XInternAtom(QX11Info::display(), "_HILDON_DO_NOT_DISTURB", False);
         if (!atom) {
             qWarning("Unable to obtain _HILDON_DO_NOT_DISTURB. This example will only work "
                      "on a Maemo 5 device!");

         if (checkState == Qt::Checked) {
             long state = 1;
                     (unsigned char *) &state,
         } else {
             XDeleteProperty(QX11Info::display(), winId(), atom);

In this example snippet, the "Do not disturb" window state is set. This window state is documented to not show any notifications of low priority if the current widget is active. As an example, changing the device's volume with its volume keys will produce a notification when the state is off, but will change the volume without notification when the state is on.

First, the _HILDON_DO_NOT_DISTURB X11 atom is retrieved from X11. If that fails, the application is not run in the Maemo 5 X11 environment.

Depending on the check state of the QCheckBox, the X11 atom is either set or cleared via XChangeProperty and XDeleteProperty. QX11Info::display() returns the root display of the current Qt application. QWidget::winId() returns the native window id of the current X11 window. Note that the atom must be set on a top-level widget. If this widget is a child widget, use QWidget::window() to determine its top-level widget.


Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();