Qt 4.8
Public Types | Public Functions | Properties | Friends | List of all members
QEasingCurve Class Reference

The QEasingCurve class provides easing curves for controlling animation. More...

#include <qeasingcurve.h>

Public Types

typedef qreal(* EasingFunction) (qreal progress)
 This is a typedef for a pointer to a function with the following signature: More...
 
enum  Type {
  Linear, InQuad, OutQuad, InOutQuad,
  OutInQuad, InCubic, OutCubic, InOutCubic,
  OutInCubic, InQuart, OutQuart, InOutQuart,
  OutInQuart, InQuint, OutQuint, InOutQuint,
  OutInQuint, InSine, OutSine, InOutSine,
  OutInSine, InExpo, OutExpo, InOutExpo,
  OutInExpo, InCirc, OutCirc, InOutCirc,
  OutInCirc, InElastic, OutElastic, InOutElastic,
  OutInElastic, InBack, OutBack, InOutBack,
  OutInBack, InBounce, OutBounce, InOutBounce,
  OutInBounce, InCurve, OutCurve, SineCurve,
  CosineCurve, Custom, NCurveTypes
}
 The type of easing curve. More...
 

Public Functions

qreal amplitude () const
 Returns the amplitude. More...
 
EasingFunction customType () const
 Returns the function pointer to the custom easing curve. More...
 
bool operator!= (const QEasingCurve &other) const
 Compare this easing curve with other and returns true if they are not equal. More...
 
QEasingCurveoperator= (const QEasingCurve &other)
 Copy other. More...
 
bool operator== (const QEasingCurve &other) const
 Compare this easing curve with other and returns true if they are equal. More...
 
qreal overshoot () const
 Returns the overshoot. More...
 
qreal period () const
 Returns the period. More...
 
 QEasingCurve (Type type=Linear)
 Constructs an easing curve of the given type. More...
 
 QEasingCurve (const QEasingCurve &other)
 Construct a copy of other. More...
 
void setAmplitude (qreal amplitude)
 Sets the amplitude to amplitude. More...
 
void setCustomType (EasingFunction func)
 Sets a custom easing curve that is defined by the user in the function func. More...
 
void setOvershoot (qreal overshoot)
 Sets the overshoot to overshoot. More...
 
void setPeriod (qreal period)
 Sets the period to period. More...
 
void setType (Type type)
 Sets the type of the easing curve to type. More...
 
Type type () const
 Returns the type of the easing curve. More...
 
qreal valueForProgress (qreal progress) const
 Return the effective progress for the easing curve at progress. More...
 
 ~QEasingCurve ()
 Destructor. More...
 

Properties

QEasingCurvePrivated_ptr
 

Friends

Q_CORE_EXPORT QDebug operator<< (QDebug debug, const QEasingCurve &item)
 
Q_CORE_EXPORT QDataStreamoperator<< (QDataStream &, const QEasingCurve &)
 Writes the given easing curve to the given stream and returns a reference to the stream. More...
 
Q_CORE_EXPORT QDataStreamoperator>> (QDataStream &, QEasingCurve &)
 

Detailed Description

The QEasingCurve class provides easing curves for controlling animation.

Since
4.6

Easing curves describe a function that controls how the speed of the interpolation between 0 and 1 should be. Easing curves allow transitions from one value to another to appear more natural than a simple constant speed would allow. The QEasingCurve class is usually used in conjunction with the QVariantAnimation and QPropertyAnimation classes but can be used on its own. It is usually used to accelerate the interpolation from zero velocity (ease in) or decelerate to zero velocity (ease out). Ease in and ease out can also be combined in the same easing curve.

To calculate the speed of the interpolation, the easing curve provides the function valueForProgress(), where the progress argument specifies the progress of the interpolation: 0 is the start value of the interpolation, 1 is the end value of the interpolation. The returned value is the effective progress of the interpolation. If the returned value is the same as the input value for all input values the easing curve is a linear curve. This is the default behaviour.

For example,

for(qreal t = 0.0; t < 1.0; t+=0.1)
qWarning() << "Effective progress" << t << " is
<< easing.valueForProgress(t);

will print the effective progress of the interpolation between 0 and 1.

When using a QPropertyAnimation, the associated easing curve will be used to control the progress of the interpolation between startValue and endValue:

animation.setStartValue(0);
animation.setEndValue(1000);
animation.setDuration(1000);

The ability to set an amplitude, overshoot, or period depends on the QEasingCurve type. Amplitude access is available to curves that behave as springs such as elastic and bounce curves. Changing the amplitude changes the height of the curve. Period access is only available to elastic curves and setting a higher period slows the rate of bounce. Only curves that have "boomerang" behaviors such as the InBack, OutBack, InOutBack, and OutInBack have overshoot settings. These curves will interpolate beyond the end points and return to the end point, acting similar to a boomerang.

The Easing Curves Example contains samples of QEasingCurve types and lets you change the curve settings.

Definition at line 55 of file qeasingcurve.h.

Typedefs

◆ EasingFunction

QEasingCurve::EasingFunction

This is a typedef for a pointer to a function with the following signature:

qreal myEasingFunction(qreal progress);

Definition at line 96 of file qeasingcurve.h.

Enumerations

◆ Type

The type of easing curve.

  • Linear
    qeasingcurve-linear.png
                    Easing curve for a linear (t) function:
                    velocity is constant.
    
  • InQuad
    qeasingcurve-inquad.png
                    Easing curve for a quadratic (t^2) function:
                    accelerating from zero velocity.
    
  • OutQuad
    qeasingcurve-outquad.png
                    Easing curve for a quadratic (t^2) function:
                    decelerating to zero velocity.
    
  • InOutQuad
    qeasingcurve-inoutquad.png
                    Easing curve for a quadratic (t^2) function:
                    acceleration until halfway, then deceleration.
    
  • OutInQuad
    qeasingcurve-outinquad.png
                    Easing curve for a quadratic (t^2) function:
                    deceleration until halfway, then acceleration.
    
  • InCubic
    qeasingcurve-incubic.png
                    Easing curve for a cubic (t^3) function:
                    accelerating from zero velocity.
    
  • OutCubic
    qeasingcurve-outcubic.png
                    Easing curve for a cubic (t^3) function:
                    decelerating to zero velocity.
    
  • InOutCubic
    qeasingcurve-inoutcubic.png
                    Easing curve for a cubic (t^3) function:
                    acceleration until halfway, then deceleration.
    
  • OutInCubic
    qeasingcurve-outincubic.png
                    Easing curve for a cubic (t^3) function:
                    deceleration until halfway, then acceleration.
    
  • InQuart
    qeasingcurve-inquart.png
                    Easing curve for a quartic (t^4) function:
                    accelerating from zero velocity.
    
  • OutQuart
    qeasingcurve-outquart.png
                    Easing curve for a quartic (t^4) function:
                    decelerating to zero velocity.
    
  • InOutQuart
    qeasingcurve-inoutquart.png
                    Easing curve for a quartic (t^4) function:
                    acceleration until halfway, then deceleration.
    
  • OutInQuart
    qeasingcurve-outinquart.png
                    Easing curve for a quartic (t^4) function:
                    deceleration until halfway, then acceleration.
    
  • InQuint
    qeasingcurve-inquint.png
                    Easing curve for a quintic (t^5) easing
                    in: accelerating from zero velocity.
    
  • OutQuint
    qeasingcurve-outquint.png
                    Easing curve for a quintic (t^5) function:
                    decelerating to zero velocity.
    
  • InOutQuint
    qeasingcurve-inoutquint.png
                    Easing curve for a quintic (t^5) function:
                    acceleration until halfway, then deceleration.
    
  • OutInQuint
    qeasingcurve-outinquint.png
                    Easing curve for a quintic (t^5) function:
                    deceleration until halfway, then acceleration.
    
  • InSine
    qeasingcurve-insine.png
                    Easing curve for a sinusoidal (sin(t)) function:
                    accelerating from zero velocity.
    
  • OutSine
    qeasingcurve-outsine.png
                    Easing curve for a sinusoidal (sin(t)) function:
                    decelerating from zero velocity.
    
  • InOutSine
    qeasingcurve-inoutsine.png
                    Easing curve for a sinusoidal (sin(t)) function:
                    acceleration until halfway, then deceleration.
    
  • OutInSine
    qeasingcurve-outinsine.png
                    Easing curve for a sinusoidal (sin(t)) function:
                    deceleration until halfway, then acceleration.
    
  • InExpo
    qeasingcurve-inexpo.png
                    Easing curve for an exponential (2^t) function:
                    accelerating from zero velocity.
    
  • OutExpo
    qeasingcurve-outexpo.png
                    Easing curve for an exponential (2^t) function:
                    decelerating from zero velocity.
    
  • InOutExpo
    qeasingcurve-inoutexpo.png
                    Easing curve for an exponential (2^t) function:
                    acceleration until halfway, then deceleration.
    
  • OutInExpo
    qeasingcurve-outinexpo.png
                    Easing curve for an exponential (2^t) function:
                    deceleration until halfway, then acceleration.
    
  • InCirc
    qeasingcurve-incirc.png
                    Easing curve for a circular (sqrt(1-t^2)) function:
                    accelerating from zero velocity.
    
  • OutCirc
    qeasingcurve-outcirc.png
                    Easing curve for a circular (sqrt(1-t^2)) function:
                    decelerating from zero velocity.
    
  • InOutCirc
    qeasingcurve-inoutcirc.png
                    Easing curve for a circular (sqrt(1-t^2)) function:
                    acceleration until halfway, then deceleration.
    
  • OutInCirc
    qeasingcurve-outincirc.png
                    Easing curve for a circular (sqrt(1-t^2)) function:
                    deceleration until halfway, then acceleration.
    
  • InElastic
    qeasingcurve-inelastic.png
                    Easing curve for an elastic
                    (exponentially decaying sine wave) function:
                    accelerating from zero velocity.  The peak amplitude
                    can be set with the \e amplitude parameter, and the
                    period of decay by the \e period parameter.
    
  • OutElastic
    qeasingcurve-outelastic.png
                    Easing curve for an elastic
                    (exponentially decaying sine wave) function:
                    decelerating from zero velocity.  The peak amplitude
                    can be set with the \e amplitude parameter, and the
                    period of decay by the \e period parameter.
    
  • InOutElastic
    qeasingcurve-inoutelastic.png
                    Easing curve for an elastic
                    (exponentially decaying sine wave) function:
                    acceleration until halfway, then deceleration.
    
  • OutInElastic
    qeasingcurve-outinelastic.png
                    Easing curve for an elastic
                    (exponentially decaying sine wave) function:
                    deceleration until halfway, then acceleration.
    
  • InBack
    qeasingcurve-inback.png
                    Easing curve for a back (overshooting
                    cubic function: (s+1)*t^3 - s*t^2) easing in:
                    accelerating from zero velocity.
    
  • OutBack
    qeasingcurve-outback.png
                    Easing curve for a back (overshooting
                    cubic function: (s+1)*t^3 - s*t^2) easing out:
                    decelerating to zero velocity.
    
  • InOutBack
    qeasingcurve-inoutback.png
                    Easing curve for a back (overshooting
                    cubic function: (s+1)*t^3 - s*t^2) easing in/out:
                    acceleration until halfway, then deceleration.
    
  • OutInBack
    qeasingcurve-outinback.png
                    Easing curve for a back (overshooting
                    cubic easing: (s+1)*t^3 - s*t^2) easing out/in:
                    deceleration until halfway, then acceleration.
    
  • InBounce
    qeasingcurve-inbounce.png
                    Easing curve for a bounce (exponentially
                    decaying parabolic bounce) function: accelerating
                    from zero velocity.
    
  • OutBounce
    qeasingcurve-outbounce.png
                    Easing curve for a bounce (exponentially
                    decaying parabolic bounce) function: decelerating
                    from zero velocity.
    
  • InOutBounce
    qeasingcurve-inoutbounce.png
                    Easing curve for a bounce (exponentially
                    decaying parabolic bounce) function easing in/out:
                    acceleration until halfway, then deceleration.
    
  • OutInBounce
    qeasingcurve-outinbounce.png
                    Easing curve for a bounce (exponentially
                    decaying parabolic bounce) function easing out/in:
                    deceleration until halfway, then acceleration.
    
  • InCurve
  • OutCurve
  • SineCurve
  • CosineCurve
  • Custom This is returned if the user specified a custom curve type with setCustomType(). Note that you cannot call setType() with this value, but type() can return it.
  • NCurveTypes
Enumerator
Linear 
InQuad 
OutQuad 
InOutQuad 
OutInQuad 
InCubic 
OutCubic 
InOutCubic 
OutInCubic 
InQuart 
OutQuart 
InOutQuart 
OutInQuart 
InQuint 
OutQuint 
InOutQuint 
OutInQuint 
InSine 
OutSine 
InOutSine 
OutInSine 
InExpo 
OutExpo 
InOutExpo 
OutInExpo 
InCirc 
OutCirc 
InOutCirc 
OutInCirc 
InElastic 
OutElastic 
InOutElastic 
OutInElastic 
InBack 
OutBack 
InOutBack 
OutInBack 
InBounce 
OutBounce 
InOutBounce 
OutInBounce 
InCurve 
OutCurve 
SineCurve 
CosineCurve 
Custom 
NCurveTypes 

Definition at line 60 of file qeasingcurve.h.

60  {
61  Linear,
74  };

Constructors and Destructors

◆ QEasingCurve() [1/2]

QEasingCurve::QEasingCurve ( Type  type = Linear)

Constructs an easing curve of the given type.

Definition at line 615 of file qeasingcurve.cpp.

617 {
618  setType(type);
619 }
Type type() const
Returns the type of the easing curve.
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
void setType(Type type)
Sets the type of the easing curve to type.

◆ QEasingCurve() [2/2]

QEasingCurve::QEasingCurve ( const QEasingCurve other)

Construct a copy of other.

Definition at line 624 of file qeasingcurve.cpp.

626 {
627  // ### non-atomic, requires malloc on shallow copy
628  *d_ptr = *other.d_ptr;
629  if (other.d_ptr->config)
630  d_ptr->config = other.d_ptr->config->copy();
631 }
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
virtual QEasingCurveFunction * copy() const

◆ ~QEasingCurve()

QEasingCurve::~QEasingCurve ( )

Destructor.

Definition at line 637 of file qeasingcurve.cpp.

638 {
639  delete d_ptr;
640 }
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102

Functions

◆ amplitude()

qreal QEasingCurve::amplitude ( ) const

Returns the amplitude.

This is not applicable for all curve types. It is only applicable for bounce and elastic curves (curves of type() QEasingCurve::InBounce, QEasingCurve::OutBounce, QEasingCurve::InOutBounce, QEasingCurve::OutInBounce, QEasingCurve::InElastic, QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic).

Definition at line 701 of file qeasingcurve.cpp.

Referenced by operator==(), setAmplitude(), and QDeclarativeEasingValueType::setValue().

702 {
703  return d_ptr->config ? d_ptr->config->_a : qreal(1.0);
704 }
double qreal
Definition: qglobal.h:1193
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config

◆ customType()

QEasingCurve::EasingFunction QEasingCurve::customType ( ) const

Returns the function pointer to the custom easing curve.

If type() does not return QEasingCurve::Custom, this function will return 0.

Definition at line 847 of file qeasingcurve.cpp.

848 {
849  return d_ptr->type == Custom ? d_ptr->func : 0;
850 }
QEasingCurve::EasingFunction func
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurve::Type type

◆ operator!=()

bool QEasingCurve::operator!= ( const QEasingCurve other) const
inline

Compare this easing curve with other and returns true if they are not equal.

It will also compare the properties of a curve.

See also
operator==()

Definition at line 82 of file qeasingcurve.h.

83  { return !(this->operator==(other)); }
bool operator==(const QEasingCurve &other) const
Compare this easing curve with other and returns true if they are equal.

◆ operator=()

QEasingCurve & QEasingCurve::operator= ( const QEasingCurve other)

Copy other.

Definition at line 645 of file qeasingcurve.cpp.

646 {
647  // ### non-atomic, requires malloc on shallow copy
648  if (d_ptr->config) {
649  delete d_ptr->config;
650  d_ptr->config = 0;
651  }
652 
653  *d_ptr = *other.d_ptr;
654  if (other.d_ptr->config)
655  d_ptr->config = other.d_ptr->config->copy();
656 
657  return *this;
658 }
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
virtual QEasingCurveFunction * copy() const

◆ operator==()

bool QEasingCurve::operator== ( const QEasingCurve other) const

Compare this easing curve with other and returns true if they are equal.

It will also compare the properties of a curve.

Definition at line 664 of file qeasingcurve.cpp.

665 {
666  bool res = d_ptr->func == other.d_ptr->func
667  && d_ptr->type == other.d_ptr->type;
668  if (res) {
669  if (d_ptr->config && other.d_ptr->config) {
670  // catch the config content
671  res = d_ptr->config->operator==(*(other.d_ptr->config));
672 
673  } else if (d_ptr->config || other.d_ptr->config) {
674  // one one has a config object, which could contain default values
675  res = qFuzzyCompare(amplitude(), other.amplitude()) &&
676  qFuzzyCompare(period(), other.period()) &&
677  qFuzzyCompare(overshoot(), other.overshoot());
678  }
679  }
680  return res;
681 }
qreal overshoot() const
Returns the overshoot.
qreal period() const
Returns the period.
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
Definition: qglobal.h:2030
qreal amplitude() const
Returns the amplitude.
QEasingCurve::EasingFunction func
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
QEasingCurve::Type type

◆ overshoot()

qreal QEasingCurve::overshoot ( ) const

Returns the overshoot.

This is not applicable for all curve types. It is only applicable if type() is QEasingCurve::InBack, QEasingCurve::OutBack, QEasingCurve::InOutBack or QEasingCurve::OutInBack.

Definition at line 749 of file qeasingcurve.cpp.

Referenced by operator==(), setOvershoot(), QEasingCurvePrivate::setType_helper(), and QDeclarativeEasingValueType::setValue().

750 {
751  return d_ptr->config ? d_ptr->config->_o : qreal(1.70158) ;
752 }
double qreal
Definition: qglobal.h:1193
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config

◆ period()

qreal QEasingCurve::period ( ) const

Returns the period.

This is not applicable for all curve types. It is only applicable if type() is QEasingCurve::InElastic, QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic.

Definition at line 725 of file qeasingcurve.cpp.

Referenced by operator==(), setPeriod(), QEasingCurvePrivate::setType_helper(), and QDeclarativeEasingValueType::setValue().

726 {
727  return d_ptr->config ? d_ptr->config->_p : qreal(0.3);
728 }
double qreal
Definition: qglobal.h:1193
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config

◆ setAmplitude()

void QEasingCurve::setAmplitude ( qreal  amplitude)

Sets the amplitude to amplitude.

This will set the amplitude of the bounce or the amplitude of the elastic "spring" effect. The higher the number, the higher the amplitude.

See also
amplitude()

Definition at line 713 of file qeasingcurve.cpp.

Referenced by QDeclarativeEasingValueType::setAmplitude().

714 {
715  if (!d_ptr->config)
717  d_ptr->config->_a = amplitude;
718 }
qreal amplitude() const
Returns the amplitude.
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
QEasingCurve::Type type

◆ setCustomType()

void QEasingCurve::setCustomType ( EasingFunction  func)

Sets a custom easing curve that is defined by the user in the function func.

The signature of the function is qreal myEasingFunction(qreal progress), where progress and the return value is considered to be normalized between 0 and 1. (In some cases the return value can be outside that range) After calling this function type() will return QEasingCurve::Custom. func cannot be zero.

See also
customType()
valueForProgress()

Definition at line 832 of file qeasingcurve.cpp.

833 {
834  if (!func) {
835  qWarning("Function pointer must not be null");
836  return;
837  }
838  d_ptr->func = func;
840 }
void setType_helper(QEasingCurve::Type)
QEasingCurve::EasingFunction func
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setOvershoot()

void QEasingCurve::setOvershoot ( qreal  overshoot)

Sets the overshoot to overshoot.

0 produces no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent.

See also
overshoot()

Definition at line 761 of file qeasingcurve.cpp.

Referenced by QDeclarativeEasingValueType::setOvershoot().

762 {
763  if (!d_ptr->config)
765  d_ptr->config->_o = overshoot;
766 }
qreal overshoot() const
Returns the overshoot.
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
QEasingCurve::Type type

◆ setPeriod()

void QEasingCurve::setPeriod ( qreal  period)

Sets the period to period.

Setting a small period value will give a high frequency of the curve. A large period will give it a small frequency.

See also
period()

Definition at line 737 of file qeasingcurve.cpp.

Referenced by QDeclarativeEasingValueType::setPeriod().

738 {
739  if (!d_ptr->config)
741  d_ptr->config->_p = period;
742 }
qreal period() const
Returns the period.
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
QEasingCurve::Type type

◆ setType()

void QEasingCurve::setType ( Type  type)

Sets the type of the easing curve to type.

Definition at line 809 of file qeasingcurve.cpp.

Referenced by operator>>(), QEasingCurve(), and QDeclarativeEasingValueType::setType().

810 {
811  if (d_ptr->type == type)
812  return;
813  if (type < Linear || type >= NCurveTypes - 1) {
814  qWarning("QEasingCurve: Invalid curve type %d", type);
815  return;
816  }
817 
819 }
void setType_helper(QEasingCurve::Type)
Type type() const
Returns the type of the easing curve.
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
Q_CORE_EXPORT void qWarning(const char *,...)
QEasingCurve::Type type

◆ type()

QEasingCurve::Type QEasingCurve::type ( ) const

Returns the type of the easing curve.

Definition at line 771 of file qeasingcurve.cpp.

Referenced by operator>>(), QEasingCurvePrivate::setType_helper(), QDeclarativeEasingValueType::setValue(), and QDeclarativeTimeLinePrivate::value().

772 {
773  return d_ptr->type;
774 }
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurve::Type type

◆ valueForProgress()

qreal QEasingCurve::valueForProgress ( qreal  progress) const

Return the effective progress for the easing curve at progress.

While progress must be between 0 and 1, the returned effective progress can be outside those bounds. For instance, QEasingCurve::InBack will return negative values in the beginning of the function.

Definition at line 858 of file qeasingcurve.cpp.

Referenced by QVariantAnimationPrivate::recalculateCurrentInterval(), and QDeclarativeTimeLinePrivate::value().

859 {
860  progress = qBound<qreal>(0, progress, 1);
861  if (d_ptr->func)
862  return d_ptr->func(progress);
863  else if (d_ptr->config)
864  return d_ptr->config->value(progress);
865  else
866  return progress;
867 }
QEasingCurve::EasingFunction func
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
virtual qreal value(qreal t)

Friends and Related Functions

◆ operator<< [1/2]

Q_CORE_EXPORT QDebug operator<< ( QDebug  debug,
const QEasingCurve item 
)
friend

Definition at line 870 of file qeasingcurve.cpp.

871 {
872  debug << "type:" << item.d_ptr->type
873  << "func:" << item.d_ptr->func;
874  if (item.d_ptr->config) {
875  debug << QString::fromAscii("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20)
876  << QString::fromAscii("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20)
877  << QString::fromAscii("overshoot:%1").arg(item.d_ptr->config->_o, 0, 'f', 20);
878  }
879  return debug;
880 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QEasingCurve::EasingFunction func
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QEasingCurve::Type type

◆ operator<< [2/2]

QDataStream & operator<< ( QDataStream stream,
const QEasingCurve easing 
)
friend

Writes the given easing curve to the given stream and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 897 of file qeasingcurve.cpp.

898 {
899  stream << quint8(easing.d_ptr->type);
900  stream << quint64(quintptr(easing.d_ptr->func));
901 
902  bool hasConfig = easing.d_ptr->config;
903  stream << hasConfig;
904  if (hasConfig) {
905  stream << easing.d_ptr->config->_p;
906  stream << easing.d_ptr->config->_a;
907  stream << easing.d_ptr->config->_o;
908  }
909  return stream;
910 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
unsigned char quint8
Definition: qglobal.h:934
QEasingCurve::EasingFunction func
static FILE * stream
unsigned __int64 quint64
Definition: qglobal.h:943
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
QEasingCurve::Type type

◆ operator>>

Q_CORE_EXPORT QDataStream& operator>> ( QDataStream ,
QEasingCurve  
)
friend

Definition at line 925 of file qeasingcurve.cpp.

926 {
928  quint8 int_type;
929  stream >> int_type;
930  type = static_cast<QEasingCurve::Type>(int_type);
931  easing.setType(type);
932 
933  quint64 ptr_func;
934  stream >> ptr_func;
935  easing.d_ptr->func = QEasingCurve::EasingFunction(quintptr(ptr_func));
936 
937  bool hasConfig;
938  stream >> hasConfig;
939  if (hasConfig) {
941  stream >> config->_p;
942  stream >> config->_a;
943  stream >> config->_o;
944  easing.d_ptr->config = config;
945  }
946  return stream;
947 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
unsigned char quint8
Definition: qglobal.h:934
QEasingCurve::EasingFunction func
Type type() const
Returns the type of the easing curve.
static FILE * stream
unsigned __int64 quint64
Definition: qglobal.h:943
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
Type
The type of easing curve.
Definition: qeasingcurve.h:60
void setType(Type type)
Sets the type of the easing curve to type.
qreal(* EasingFunction)(qreal progress)
This is a typedef for a pointer to a function with the following signature:
Definition: qeasingcurve.h:96

Properties

◆ d_ptr

QEasingCurvePrivate* QEasingCurve::d_ptr
private

The documentation for this class was generated from the following files: