How to vibrate a device using Qt/QML on both Android and IOS



  • Hi folks, I'm looking for that piece of module in Qt/QML, to vibrate a device for a time period in demand. Also, I expect that module to work both on Android and IOS flawlessly. Is there anyone who has previously worked on this item?

    Thank you



  • Hi Yashpal!

    You can have a look at V-Play Engine for Qt-based mobile apps and games. It offers a NativeUtils component which allows to trigger native features for both iOS and Android, as well as many other components to make mobile development with Qt easier.

    It's possible to vibrate the phone with a simple method call:

    App {
      AppButton {
        text: "vibrate"
        onClicked: {
          nativeUtils.vibrate()
        }
      }
    } 
    

    Best,
    GTDev



  • @GTDev Yes, I went through Vplay documentation, really fab stuff. Now that all I want know is how to control the duration of vibration. Think that, I want the device to vibrate for say 2 seconds, 4 seconds and 6 seconds respectively now, how can we do this?



  • Hi,

    V-Play as a cross-platform engine allows to vibrate the iOS or Android device with a single method call, which then triggers the native iOS or Android vibration features.

    On Android, it is possible to specify the vibration duration, but iOS currently does not allow to change the duration with their public API. So the vibrate() function only tells the phone to vibrate on iOS and on Android a default duration of 300ms is used.

    Best,
    GTDev


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.