The QFeedbackHapticsEffect class allows you to play a haptics effect. More...
#include <QFeedbackHapticsEffect>
Inherits QFeedbackEffect.
|
|
QFeedbackHapticsEffect ( QObject * parent = 0 ) | |
~QFeedbackHapticsEffect () | |
QFeedbackActuator * | actuator () const |
qreal | attackIntensity () const |
int | attackTime () const |
qreal | fadeIntensity () const |
int | fadeTime () const |
qreal | intensity () const |
int | period () const |
void | setActuator ( QFeedbackActuator * actuator ) |
void | setAttackIntensity ( qreal intensity ) |
void | setAttackTime ( int msecs ) |
void | setDuration ( int msecs ) |
void | setFadeIntensity ( qreal intensity ) |
void | setFadeTime ( int msecs ) |
void | setIntensity ( qreal intensity ) |
void | setPeriod ( int msecs ) |
virtual int | duration () const |
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:
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: attackTime() + duration() + fadeTime().
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.
This property holds the actuator on which the effect operates.
This property defines the actuator on which the effect operates. You can only change the actuator used when the effect is stopped.
Access functions:
QFeedbackActuator * | actuator () const |
void | setActuator ( QFeedbackActuator * actuator ) |
This property holds the initial intensity of the effect.
This property defines the initial intensity of the effect, before it fades in. It is usually lower than intensity.
Access functions:
qreal | attackIntensity () const |
void | setAttackIntensity ( qreal intensity ) |
This property holds the duration of the fade-in effect.
This property defines the duration of the fade-in effect in milliseconds.
Access functions:
int | attackTime () const |
void | setAttackTime ( int msecs ) |
This property holds the expected duration of the effect.
This property defines the duration of the feedback effect, in milliseconds.
Access functions:
virtual int | duration () const |
void | setDuration ( int msecs ) |
This property holds the final intensity of the effect.
This property defines the final intensity of the effect, after it fades out. It is usually lower than intensity.
Access functions:
qreal | fadeIntensity () const |
void | setFadeIntensity ( qreal intensity ) |
This property holds the duration of the fade-out effect.
This property defines the duration of the fade-out effect in milliseconds.
Access functions:
int | fadeTime () const |
void | setFadeTime ( int msecs ) |
This property holds the intensity of the effect.
This property defines the intensity of the feedback effect. The value can be between 0 and 1.
Access functions:
qreal | intensity () const |
void | setIntensity ( qreal intensity ) |
This property holds set the period for the effect.
It has a default value of -1, which means that it is not a periodic effect. You can only change the period when the effect is stopped. Note: Not all actuators support periodic effects
Access functions:
int | period () const |
void | setPeriod ( int msecs ) |
Constructs the QFeedbackHapticsEffect class, and passes parent to QObject's constructor. The default QFeedbackActuator will be used.
See also QFeedbackActuator::actuators().
Destroys this effect and stops the feedback if it is running.