How to use QtMobility to enable vibration in QML
hamishwillee
(Talk | contribs) m (Hamishwillee - Fix internal links in external format) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (3 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category:Qt Quick]][[Category:Qt Mobility]][[Category: | + | [[Category:Qt Quick]][[Category:Qt Mobility]][[Category:Symbian]][[Category:MeeGo Harmattan]][[Category:UI]] |
| − | + | {{Abstract|This article explains how to use QtMobility to enable vibration in QML.}} This uses an alternative mechanism to that proposed in [[How to use QVibra to enable vibration in QML]]. | |
| − | + | ||
| − | {{Abstract|This article explains how to use QtMobility to enable vibration in QML.}} | + | |
{{ArticleMetaData <!-- v1.2 --> | {{ArticleMetaData <!-- v1.2 --> | ||
| − | |sourcecode= | + | |sourcecode= [[Media:Ltdk vibrationQML.zip]] |
| − | |installfile= | + | |installfile= [[Media:Ltdk vibrationQML.sis]] |
|devices= Nokia E7-00, Nokia N950 | |devices= Nokia E7-00, Nokia N950 | ||
|sdk= [https://www.developer.nokia.com/Develop/Qt/Tools/ Qt SDK 1.1.4] | |sdk= [https://www.developer.nokia.com/Develop/Qt/Tools/ Qt SDK 1.1.4] | ||
|platform= Compatible platforms: Symbian^3 and later, Meego | |platform= Compatible platforms: Symbian^3 and later, Meego | ||
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| − | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| − | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | + | |signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> |
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
|translated-by= <!-- [[User:XXXX]] --> | |translated-by= <!-- [[User:XXXX]] --> | ||
| − | |translated-from-title= <!-- Title only --> | + | |translated-from-title= <!-- Title only --> |
|translated-from-id= <!-- Id of translated revision --> | |translated-from-id= <!-- Id of translated revision --> | ||
| − | |review-by=<!-- After re-review: [[User:username]] --> | + | |review-by= <!-- After re-review: [[User:username]] --> |
|review-timestamp= <!-- After re-review: YYYYMMDD --> | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
|update-by= <!-- After significant update: [[User:username]]--> | |update-by= <!-- After significant update: [[User:username]]--> | ||
| Line 26: | Line 24: | ||
|author= [[User:ltdangkhoa2105]] | |author= [[User:ltdangkhoa2105]] | ||
}} | }} | ||
| − | |||
| − | |||
| − | |||
| − | |||
== Step by step == | == Step by step == | ||
In the project file, put these settings first: | In the project file, put these settings first: | ||
| − | |||
<code> | <code> | ||
... | ... | ||
| − | |||
CONFIG += mobility | CONFIG += mobility | ||
MOBILITY += feedback | MOBILITY += feedback | ||
| − | |||
... | ... | ||
</code> | </code> | ||
| Line 47: | Line 38: | ||
<code> | <code> | ||
| − | |||
import QtMobility.feedback 1.1 | import QtMobility.feedback 1.1 | ||
| Line 67: | Line 57: | ||
Ok, now wherever you want to start the vibration, just easily call the rumbleEffect | Ok, now wherever you want to start the vibration, just easily call the rumbleEffect | ||
| − | <code cpp> | + | <code cpp-qt> |
... | ... | ||
appWindow.rumbleEffect.start(); | appWindow.rumbleEffect.start(); | ||
| Line 74: | Line 64: | ||
== Sample source code == | == Sample source code == | ||
| − | You can download the sample source code of this article from below links | + | You can download the sample source code of this article from below links |
| − | [[File: | + | * [[File:Ltdk vibrationQML.zip]] |
| − | + | * [[File:Ltdk vibrationQML.sis]] | |
| − | [[File: | + | [[Category:Code Examples]] |
Latest revision as of 04:20, 11 October 2012
This article explains how to use QtMobility to enable vibration in QML. This uses an alternative mechanism to that proposed in How to use QVibra to enable vibration in QML.
Article Metadata
Code Example
Source file: Media:Ltdk vibrationQML.zip
Installation file: Media:Ltdk vibrationQML.sis
Tested with
SDK: Qt SDK 1.1.4
Devices(s): Nokia E7-00, Nokia N950
Compatibility
Platform(s): Compatible platforms: Symbian^3 and later, Meego
Article
Created: ltdangkhoa2105
(06 Mar 2012)
Last edited: hamishwillee
(11 Oct 2012)
Step by step
In the project file, put these settings first:
...
CONFIG += mobility
MOBILITY += feedback
...
Next step, I'll put some of these code below to main.qml file
import QtMobility.feedback 1.1
PageStackWindow {
id: appWindow
HapticsEffect {
id: rumbleEffect
attackIntensity: 0.0
attackTime: 250
intensity: 1.0
duration: 250 // set up the duration here, in millisecond
fadeTime: 250
fadeIntensity: 0.0
}
}
Ok, now wherever you want to start the vibration, just easily call the rumbleEffect
...
appWindow.rumbleEffect.start();
...
Sample source code
You can download the sample source code of this article from below links

