QFeedbackHapticsEffect Class
The QFeedbackHapticsEffect class allows you to play a haptics effect. More...
| Header: | #include <QFeedbackHapticsEffect> |
| Inherits: | QFeedbackEffect |
Additional Inherited Members
- 2 public functions inherited from QFeedbackEffect
- 2 protected functions inherited from QFeedbackEffect
Detailed Description
The QFeedbackHapticsEffect class allows you to play a haptics effect.
A haptics effect is an effect that takes advantage of the sense of touch. Most mobile devices today supports one such effect, vibration, which will then be the default when you create a QFeedbackHapticsEffect.
A haptics effect has a few parameters that must be set up before it can be played:
- duration(): The total duration of the effect in milliseconds.
- intensity(): The intensity, e.g., how hard the device will vibrate.
An effect can, for example, be set up as follows:
QFeedbackHapticsEffect rumble; rumble.setIntensity(1.0); rumble.setDuration(100);
You can now start() the effect.
rumble.start();
At any given time, the effect is in one of four states: Stopped, Paused, Running, or Loading. You can request a state change by calling start(), pause(), or stop(). The state is queried with state().
The haptics effect also supports a fade-in of the effect. For vibration, this means that the vibration will grow (or sink) in intensity from when the effect starts until intensity() is reached. You can set that up as follows:
rumble.setAttackIntensity(0.0); rumble.setAttackTime(250);
Attack intensity is the start intensity and attack time is the duration of the fade-in. We have a similar fade-out:
rumble.setFadeTime(250); rumble.setFadeIntensity(0.0);
When using fade-in and fade-out the total duration of the haptics effect will be: duration(); the main intensity() will be played for (duration() - (attackTime() + fadeTime())) milliseconds.
A QFeedbackHapticsEffect is played on an actuator(), which is the physical component that performs the effect. You can query if other actuators are available - see the QFeedbackActuator::actuators() function documentation for details.
Errors occurring during playback are notified through the error() signal.
See also QFeedbackActuator.