PySide6.QtCore.QVariantAnimation¶
- class QVariantAnimation¶
- The - QVariantAnimationclass provides a base class for animations. More…- Inherited by: - QPropertyAnimation- Added in version 4.6. - Synopsis¶- Properties¶- currentValueᅟ- The current value of the animation
- durationᅟ- The duration of the animation
- easingCurveᅟ- The easing curve of the animation
- endValueᅟ- The end value of the animation
- startValueᅟ- The optional start value of the animation
 - Methods¶- def - __init__()
- def - currentValue()
- def - easingCurve()
- def - endValue()
- def - keyValueAt()
- def - keyValues()
- def - setDuration()
- def - setEasingCurve()
- def - setEndValue()
- def - setKeyValueAt()
- def - setKeyValues()
- def - setStartValue()
- def - startValue()
 - Virtual methods¶- def - interpolated()
 - Signals¶- def - valueChanged()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - This class is part of The Animation Framework . It serves as a base class for property and item animations, with functions for shared functionality. - The class performs interpolation over - QVariants, but leaves using the interpolated values to its subclasses. Currently, Qt provides- QPropertyAnimation, which animates Qt properties . See the- QPropertyAnimationclass description if you wish to animate such properties.- You can then set start and end values for the property by calling - setStartValue()and- setEndValue(), and finally call- start()to start the animation.- QVariantAnimationwill interpolate the property of the target object and emit- valueChanged(). To react to a change in the current value you have to reimplement the- updateCurrentValue()virtual function or connect to said signal.- It is also possible to set values at specified steps situated between the start and end value. The interpolation will then touch these points at the specified steps. Note that the start and end values are defined as the key values at 0.0 and 1.0. - There are two ways to affect how - QVariantAnimationinterpolates the values. You can set an easing curve by calling- setEasingCurve(), and configure the duration by calling- setDuration(). You can change how the- QVariants are interpolated by creating a subclass of- QVariantAnimation, and reimplementing the virtual- interpolated()function.- Subclassing - QVariantAnimationcan be an alternative if you have- QVariants that you do not wish to declare as Qt properties. Note, however, that you in most cases will be better off declaring your- QVariantas a property.- Not all - QVarianttypes are supported. Below is a list of currently supported- QVarianttypes:- If you need to interpolate other variant types, including custom types, you have to implement interpolation for these yourself. To do this, you can register an interpolator function for a given type. This function takes 3 parameters: the start value, the end value, and the current progress. - Example: - def myColorInterpolator(start,end,progress): ... return QColor(...) ... qRegisterAnimationInterpolator<QColor>(myColorInterpolator) - Another option is to reimplement - interpolated(), which returns interpolation values for the value being interpolated.- Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property currentValueᅟ: object¶
 - This property holds the current value of the animation.. - This property describes the current value; an interpolated value between the - start valueand the- end value, using the current time for progress. The value itself is obtained from- interpolated(), which is called repeatedly as the animation is running.- QVariantAnimationcalls the virtual- updateCurrentValue()function when the current value changes. This is particularly useful for subclasses that need to track updates. For example,- QPropertyAnimationuses this function to animate Qt properties .- See also - Access functions:
- Signal - valueChanged()
 
 - property durationᅟ: int¶
 - This property holds the duration of the animation. - This property describes the duration in milliseconds of the animation. The default duration is 250 milliseconds. - See also - Access functions:
 - property easingCurveᅟ: QEasingCurve¶
 - This property holds the easing curve of the animation. - This property defines the easing curve of the animation. By default, a linear easing curve is used, resulting in linear interpolation. Other curves are provided, for instance, - InCirc, which provides a circular entry curve. Another example is- InOutElastic, which provides an elastic effect on the values of the interpolated variant.- QVariantAnimationwill use the- valueForProgress()to transform the “normalized progress” (currentTime / totalDuration) of the animation into the effective progress actually used by the animation. It is this effective progress that will be the progress when- interpolated()is called. Also, the steps in the- keyValuesare referring to this effective progress.- The easing curve is used with the interpolator, the - interpolated()virtual function, and the animation’s duration to control how the current value changes as the animation progresses.- Access functions:
 - property endValueᅟ: object¶
 - This property holds the end value of the animation. - This property describes the end value of the animation. - See also - Access functions:
 - property startValueᅟ: object¶
 - This property holds the optional start value of the animation. - This property describes the optional start value of the animation. If omitted, or if a null - QVariantis assigned as the start value, the animation will use the current position of the end when the animation is started.- See also - Access functions:
 - Construct a - QVariantAnimationobject.- parentis passed to- QAbstractAnimation‘s constructor.- currentValue()¶
- Return type:
- object 
 
 - Getter of property - currentValueᅟ.- easingCurve()¶
- Return type:
 - See also 
 - Getter of property - easingCurveᅟ.- endValue()¶
- Return type:
- object 
 - See also 
 - Getter of property - endValueᅟ.- interpolated(from, to, progress)¶
- Parameters:
- from – object 
- to – object 
- progress – float 
 
- Return type:
- object 
 
 - This virtual function returns the linear interpolation between variants - fromand- to, at- progress, usually a value between 0 and 1. You can reimplement this function in a subclass of- QVariantAnimationto provide your own interpolation algorithm.- Note that in order for the interpolation to work with a - QEasingCurvethat return a value smaller than 0 or larger than 1 (such as- InBack) you should make sure that it can extrapolate. If the semantic of the datatype does not allow extrapolation this function should handle that gracefully.- You should call the - QVariantAnimationimplementation of this function if you want your class to handle the types already supported by Qt (see class- QVariantAnimationdescription for a list of supported types).- See also - keyValueAt(step)¶
- Parameters:
- step – float 
- Return type:
- object 
 
 - Returns the key frame value for the given - step. The given- stepmust be in the range 0 to 1. If there is no KeyValue for- step, it returns an invalid- QVariant.- See also - keyValues()¶
- Return type:
- .list of std.pairdouble,QVariant 
 
 - Returns the key frames of this animation. - See also - setDuration(msecs)¶
- Parameters:
- msecs – int 
 - See also - duration()
 - Setter of property - durationᅟ.- setEasingCurve(easing)¶
- Parameters:
- easing – - QEasingCurve
 - See also 
 - Setter of property - easingCurveᅟ.- setEndValue(value)¶
- Parameters:
- value – object 
 - See also 
 - Setter of property - endValueᅟ.- setKeyValueAt(step, value)¶
- Parameters:
- step – float 
- value – object 
 
 
 - Creates a key frame at the given - stepwith the given- value. The given- stepmust be in the range 0 to 1.- See also - setKeyValues(values)¶
- Parameters:
- values – .list of std.pairdouble,QVariant 
 
 - Replaces the current set of key frames with the given - keyValues. the step of the key frames must be in the range 0 to 1.- See also - setStartValue(value)¶
- Parameters:
- value – object 
 - See also 
 - Setter of property - startValueᅟ.- startValue()¶
- Return type:
- object 
 - See also 
 - Getter of property - startValueᅟ.- updateCurrentValue(value)¶
- Parameters:
- value – object 
 
 - This virtual function is called every time the animation’s current value changes. The - valueargument is the new current value.- The base class implementation does nothing. - See also - valueChanged(value)¶
- Parameters:
- value – object 
 
 - QVariantAnimationemits this signal whenever the current- valuechanges.- See also - Notification signal of property - currentValueᅟ.