## Handling locked screen event in Qt for Maemo

If you want to pause an application to save battery power when the screen is turned off, you can do this by listening for the locked screen event in Qt for Maemo. However, this is not made easily available through a wrapper function (that I know of), so in this case we’ll need to resort to listening for the right DBus call. (Thanks to Diph from Maemo.org for providing the recipe to make this possible.)

First of all, you’ll need to enable dbus in your project (.pro) file:

maemo5 {
CONFIG += qdbus
}

#ifdef Q_WS_MAEMO_5
#include <QtDBus/QtDBus>
#endif

And you’ll need to add a slot for the screen state change:

## Handling application minimization in Maemo with Qt

When you are developing with Qt on Maemo you might want to minimize or detect minimization of your application to the dashboard. Qt lacks clean functions for these use cases, but thankfully it’s still very easy to accomplish them.

### Minimizing the application

First of all, to minimize your application you’ll need to add the following CONFIG line to your project file (the .pro file):

maemo5 {
CONFIG += qdbus
}

Then, in your .cpp or .h file, you’ll need to include the QtDBus headers:

#ifdef Q_WS_MAEMO_5
#include <QtDBus/QtDBus>
#endif

You may of course skip the #ifdef statements if you’d like DBus for other systems as well, but here I’d like to make this exception only for Maemo. Now, anywhere in your application you may add the following lines to minimize to Maemo’s dashboard: