[Solved] qtMobility.feedback HapticsEffect does not do what I want
I want to get 30 seconds vibration like what a call is coming does.
My code is
- import QtQuick 1.1
- import com.nokia.symbian 1.1
- import QtMobility.feedback 1.1
- Page {
- id: mainPage
- Text {
- id:helloWordText
- anchors.centerIn: parent
- text: qsTr("Hello world!")
- color: platformStyle.colorNormalLight
- font.pixelSize: 20
- }
- Button {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: helloWordText.bottom
- text: qsTr("Vibration")
- HapticsEffect {
- id: rumbleEffect
- intensity: 1.0
- duration: 30000
- }
- MouseArea {
- onClicked: {
- rumbleEffect.start(); // plays a rumble effect
- }
- }
- }
- }
And my .pro file is
- # Add more folders to ship with the application, here
- folder_01.source = qml/testOfVibration
- folder_01.target = qml
- DEPLOYMENTFOLDERS = folder_01
- # Additional import path used to resolve QML modules in Creator's code model
- QML_IMPORT_PATH =
- symbian:TARGET.UID3 = 0xE335C713
- # Smart Installer package's UID
- # This UID is from the protected range and therefore the package will
- # fail to install if self-signed. By default qmake uses the unprotected
- # range value if unprotected UID is defined for the application and
- # 0x2002CCCF value if protected UID is given to the application
- #symbian:DEPLOYMENT.installer_header = 0x2002CCCF
- # Allow network access on Symbian
- symbian:TARGET.CAPABILITY += NetworkServices
- # If your application uses the Qt Mobility libraries, uncomment the following
- # lines and add the respective components to the MOBILITY variable.
- # CONFIG += mobility
- # MOBILITY +=
- # Speed up launching on MeeGo/Harmattan when using applauncherd daemon
- # CONFIG += qdeclarative-boostable
- # Add dependency to Symbian components
- CONFIG += qt-components
- CONFIG += mobility
- MOBILITY = feedback
- # The .cpp file which was generated for your project. Feel free to hack it.
- SOURCES += main.cpp
- # Please do not modify the following two lines. Required for deployment.
- include(qmlapplicationviewer/qmlapplicationviewer.pri)
- qtcAddDeployment()
However, what I get is, when I press the button, the phone will vibrate, but only for a very small period of time, something like when you type in the native virtual keyboard. I have set duration to 30 seconds, but it does work. Anyone know why?
Thank you.
5 replies
Here’s the docs on Symbian Haptics.
http://library.developer.nokia.com/topic/GUID-E35887BB-7E58-438C-AA27-97B2CDE7E069/GUID-251A35C1-CC66-4DE4-9EBE-964026E89E7F/GUID-2D2EBEA7-4E61-30AF-A09A-153F4C55BB53.html
The part of interest is
- Duration of the effect. Unit is milliseconds.
- To specify an infinite duration, the effect duration should be set to InfiniteDuration(). For a finite duration, the effect duration is clamped to a value from 0 to the value returned by GetDeviceCapability() for the EHWRMHapticsMaxEffectDuration capability type.
Both the Symbian and Qt docs suggest that an infinite value can be used for an ongoing effect, so try:
- HapticsEffect {
- id: rumbleEffect
- intensity: 1.0
- duration: Feedback.Infinite
- Timer { id: stoptimer; interval: 30000; onTriggered: rumbleEffect.stop() }
- }
- MouseArea {
- onClicked: {
- rumbleEffect.start(); // plays a rumble effect
- stoptimer.restart(); // Kill after 30s if not re-fired
- }
- }
using a Timer to control the stop() behaviour.
Otherwise, if the above fails, you would likely need to fire off in succession enough HapticsEffect loops to get the vibration time you want.
Unfortunately it seems the API is unable to give you that magic duration – and chances are it’s device specific. Choosing a small number, e.g. 2000ms and repeating that might be ok.
I find a project for this.
here.QVibra
www.developer.nokia.com/Community/Wiki/How_to_use_QVibra_to_enable_vibration_in_QML
You must log in to post a reply. Not a member yet? Register here!

