Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 01:20, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to use QtMobility to enable vibration in QML

From Wiki
Jump to: navigation, search

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
Installation file: Media:Ltdk vibrationQML.sis
Tested with
Devices(s): Nokia E7-00, Nokia N950
Compatibility
Platform(s): Compatible platforms: Symbian^3 and later, Meego
Symbian
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

This page was last modified on 11 October 2012, at 01:20.
54 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×