Qt Mobility Reference Documentation

QFeedbackHapticsEffect Class Reference

The QFeedbackHapticsEffect class allows you to play a haptics effect. More...

 #include <QFeedbackHapticsEffect>

Inherits QFeedbackEffect.


Properties


Public Functions

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 )

Reimplemented Public Functions

virtual int duration () const

Additional Inherited Members


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 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: 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.


Property Documentation

actuator : 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 )

attackIntensity : qreal

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 )

attackTime : int

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 )

duration : int

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 )

fadeIntensity : int

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 )

fadeTime : int

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 )

intensity : qreal

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 )

period : int

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 )

Member Function Documentation

QFeedbackHapticsEffect::QFeedbackHapticsEffect ( QObject * parent = 0 )

Constructs the QFeedbackHapticsEffect class, and passes parent to QObject's constructor. The default QFeedbackActuator will be used.

See also QFeedbackActuator::actuators().

QFeedbackHapticsEffect::~QFeedbackHapticsEffect ()

Destroys this effect and stops the feedback if it is running.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.