Qt4 and Hildon home widget interaction

The code in this wiki page is taken from the dlh application and the dlh widget. Since it is FOSS, the source code is available for anyone to adapt freely.

[edit] Service

The com.nokia.dlh.service file defines the D-Bus service provided by the Qt4 application:

[D-BUS Service]

There's a reference to this service in the dlh.desktop file too:


[edit] Application

In the class definition of the objects which will interact with the home widget you need the Q_CLASSINFO macro:

class Widget : public QWidget
    Q_CLASSINFO("D-Bus Interface", "com.nokia.dlh")

The slots have the same name of the D-Bus messages; Q_NOREPLY mark a method to be called and not wait for it to finish processing before returning (see Qt docs):

Q_NOREPLY void CallStartDialog();

The class constructor contains the service and the object registration:

QDBusConnection::sessionBus().registerObject("/com/nokia/dlh",this, QDBusConnection::ExportAllContents);

[edit] Home Widget

Some defines:

#define DLH_SERVICE "com.nokia.dlh"
#define DLH_OBJECT  "/com/nokia/dlh"
#define DLH_IFACE   "com.nokia.dlh"

In the init function you have to initialize the osso library (see libosso docs):

osso_context = osso_initialize ("com.nokia.dlh-widget", "0.1", 0, NULL);

When you want to execute the Qt object's slot CallStartDialog from the home widget you will use the following instruction:

             "CallStartDialog", NULL, DBUS_TYPE_INVALID);

That's all!