D-Bus hat Signale (keine Qt-Signale, aber sie werden Signalen zugeordnet, wenn sie mit QDBusAbstractAdaptor
verwendet werden).
This example zeigt einen Server D-Bus-Objekt, das Benachrichtigungen an die Kunden senden können:
class MainApplicationAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.DBus.MainApplication")
Q_PROPERTY(QString caption READ caption WRITE setCaption)
Q_PROPERTY(QString organizationName READ organizationName)
Q_PROPERTY(QString organizationDomain READ organizationDomain)
...
signals:
void aboutToQuit();
void mainWindowHasFocus();
};
Schnittstellendefinition:
interface org.kde.DBus.MainApplication
{
property readwrite STRING caption
property read STRING organizationName
property read STRING organizationDomain
method quit() annotation("org.freedesktop.DBus.Method.NoReply", "true")
method reparseConfiguration()
method mainWindowObject(out STRING)
method disableSessionManagement(in BOOLEAN enable)
signal aboutToQuit()
signal mainWindowHasFocus()
}