×
Namespaces

Variants
Actions
(Difference between revisions)

How to use QtMobility to enable vibration in QML

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Fix internal links in external format)
hamishwillee (Talk | contribs)
m (Hamishwillee - Tidy wiki text)
Line 1: Line 1:
[[Category:Qt Quick]][[Category:Qt Mobility]][[Category:Device Management]][[Category:Symbian]][[Category:MeeGo]]
+
[[Category:Qt Quick]][[Category:Qt Mobility]][[Category:Symbian]][[Category:MeeGo]][[Category:UI]]
{{Note|This is an entry in the [[Symbian Qt Quick Components Competition 2012Q1]]}}
+
{{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= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
+
|sourcecode= [[Media:Ltdk_vibrationQML.zip]]
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
+
|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]
Line 26: Line 24:
 
|author= [[User:ltdangkhoa2105]]
 
|author= [[User:ltdangkhoa2105]]
 
}}
 
}}
 
== Introduction ==
 
 
As the previous article : [[How to use QVibra to enable vibration in QML]]. This article will show another way to implement vibration using QML
 
  
 
== 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 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:Ltdk_vibrationQML.zip]]<br />
+
* [[File:Ltdk_vibrationQML.zip]]
 
+
* [[File:Ltdk_vibrationQML.sis]]
[[File:Ltdk_vibrationQML.sis]]
+

Revision as of 09:02, 18 April 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
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 (18 Apr 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

74 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.

×