Note that this method could have also been written: void mainWindowObject( QString &path). mainWindowObject: this method takes no input parameter, but returns one string output argument, containing the path to the main window object (if the application has a main window), or an empty string if it has no main window.reparseConfiguration: this simple method, with no input or output arguments simply relays the call to the application's reparseConfiguration member function.See Q_NOREPLY for more information on asynchronous methods This is represented in D-Bus by the use of the .NoReply annotation. That is, callers are expected to use "fire-and-forget" mechanism when calling this method, since it provides no useful reply. quit: this method takes no parameters and is defined to be asynchronous.
This snippet of code defines 4 methods with different properties each: The public slots in the example (which will be exported as D-Bus methods) are the following: An eventual destructor could be used to emit one last signal before the object is destroyed, for instance. Note that there is no destructor in the example. it connects the application's signal focusChanged to a private slot to do some further processing before emitting a D-Bus signal.it connects the application's signal aboutToQuit to its own signal aboutToQuit.Note that it would be possible to access the same object using the QDBusAbstractAdaptor::object() function, but it would be necessary to use static_cast to properly access the methods in QApplication that are not part of QObject. it stores the app pointer in a member variable.it initialises its base class ( QDBusAbstractAdaptor) with the parent object it is related to.MyInterfaceAdaptor( QApplication *application)Ĭonnect(application, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit()) The code above would create an interface that could be represented more or less in the following canonical representation: Void focusChangedSlot( QWidget *, QWidget *now) Void setCaption( const QString &newCaption)Īpp - >mainWindow() - >setCaption(newCaption) Return QString( "") // must not return a null QString SLOT(focusChangedSlot( QWidget *, QWidget *))) : QDBusAbstractAdaptor(application), app(application)Ĭonnect(application, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit())) Ĭonnect(application, SIGNAL(focusChanged( QWidget *, QWidget *)) , MainApplicationAdaptor( QApplication *application) Q_PROPERTY( QString organizationDomain READ organizationDomain) Q_PROPERTY( QString organizationName READ organizationName) Q_PROPERTY( QString caption READ caption WRITE setCaption) Class MainApplicationAdaptor: public QDBusAbstractAdaptor