Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] qtMobility.feedback HapticsEffect does not do what I want
Qt 6.11 is out! See what's new in the release blog

[Solved] qtMobility.feedback HapticsEffect does not do what I want

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      You may be exceeding the maximum time for an effect. I don't recall exactly how it works for Symbian, but it may be defaulting to a small number and discarding the 300000.
      Try three seconds and if that works, then that's likely the issue.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Then what should I do if I want to do a 30 seconds vibration? The feedback api is not fit for me? Is there any other api can do this?

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            The duration is an int property. So I get the error here:"duration: Feedback.Infinite"
            @Unable to assign [undefined] to int duration@

            But the vibration this time is much stronger.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              I find a project for this.
              here.QVibra
              "www.developer.nokia.com/Community/Wiki/How_to_use_QVibra_to_enable_vibration_in_QML":www.developer.nokia.com/Community/Wiki/How_to_use_QVibra_to_enable_vibration_in_QML

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved