Editing Documentation/Maemo 5 Developer Guide/Development Environment/Maemo Programming Environments/Using Maemo 5 specific APIs in Qt application
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
- | = | + | == Introduction == |
- | + | This section explains how to use [[Accelerometers | accelerometer]] D-Bus interface in Maemo 5 Qt application. | |
- | + | ||
- | + | ||
- | + | ||
- | This section explains how to use | + | |
The following code examples are used in this section: | The following code examples are used in this section: | ||
- | * [https:// | + | * [https://garage.maemo.org/svn/maemoexamples/trunk/qt-maemo-gravity-example/ qt-maemo-gravity-example] |
- | + | == D-Bus interface == | |
- | It | + | It's up to each application how to organize interactions with [http://maemo.org/api_refs/5.0/beta/mce-dev/ MCE] orientation interface. In [[Documentation/Maemo 5 Developer Guide/Porting Software/Porting Existing GTK+ Application to Maemo 5#Portrait Mode | some cases]] catching orientation signal can be enough, but if e.g. more frequent updates are needed you might want to use method calls, that demonstrated in our example. |
- | We've moved D-Bus related functionality and orientation based calculations to | + | We've moved D-Bus related functionality and orientation based calculations to separate library, that implements `DeviceOrientationNotifier' class. |
- | Our notifier asks MCE about orientation parameters with | + | Our notifier asks MCE about orientation parameters with certain period, |
- | + | void DeviceOrientationNotifier::mceOrientationCall() | |
- | void DeviceOrientationNotifier:: | + | { |
- | { | + | QDBusMessage msg = QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET); |
- | + | bool sent = QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(mceOrientationSlot(QString, QString, QString, int, int, int))); | |
- | + | } | |
- | } | + | processes answers in `mceOrientationSlot' and emits data needed by application with following signal. |
- | + | void deviceOrientation(qreal pitch, qreal roll); | |
- | processes answers in `mceOrientationSlot' | + | |
- | + | ||
- | void deviceOrientation(qreal pitch, qreal roll); | + | |
- | + | ||
- | + | == Example application == | |
We've modified [http://qt.nokia.com/doc/4.5/graphicsview-collidingmice.html one of Qt4 Examples] in order to show how device orientation can be used. | We've modified [http://qt.nokia.com/doc/4.5/graphicsview-collidingmice.html one of Qt4 Examples] in order to show how device orientation can be used. | ||
- | In our case pitch and roll are scene's characteristics, so we've implemented | + | In our case pitch and roll are scene's characteristics, so we've implemented `SceneTuner', that's slot can be connected to appropriate signal in order to setup these scene's properties. |
- | + | DeviceOrientationNotifier notifier(100); | |
- | DeviceOrientationNotifier notifier(100); | + | SceneTuner tuner(&scene); |
- | SceneTuner tuner(&scene | + | QObject::connect(¬ifier, SIGNAL(deviceOrientation(qreal, qreal)), &tuner, SLOT(setProps(qreal, qreal))); |
- | QObject::connect(¬ifier, SIGNAL(deviceOrientation(qreal, qreal)), &tuner, SLOT(setProps(qreal, qreal))); | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | Based on that each mouse can take into account gravity effect, see `Mouse::timerEvent' for details. | |
- | + | ||
- | + |
Learn more about Contributing to the wiki.