- Qt 6.11
- Qt 3D
- C++ Classes
- Qt3DInput (Deprecated)
- QAxisAccumulator
- Qt 6.11.2 Reference Documentation

# Qt3DInput::QAxisAccumulator Class

class Qt3DInput::QAxisAccumulator

QAxisAccumulator processes velocity or acceleration data from a QAxis. More...

Header: | `#include <QAxisAccumulator>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS 3dinput)` `target_link_libraries(mytarget PRIVATE Qt6::3dinput)`
qmake: | `QT += 3dinput`
In QML: | AxisAccumulator
Inherits: | Qt3DCore::QComponent
Status: | Deprecated

- List of all members, including inherited members

## Public Types

enum | SourceAxisType { Velocity, Acceleration }

## Properties

scale : float sourceAxis : Qt3DInput::QAxis* sourceAxisType : SourceAxisType | value : float velocity : float

## Public Functions

| QAxisAccumulator(Qt3DCore::QNode *parent = nullptr)
float | scale() const
Qt3DInput::QAxis * | sourceAxis() const
Qt3DInput::QAxisAccumulator::SourceAxisType | sourceAxisType() const
float | value() const
float | velocity() const

## Public Slots

void | setScale(float scale)
void | setSourceAxis(Qt3DInput::QAxis *sourceAxis)
void | setSourceAxisType(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

## Signals

void | scaleChanged(float scale)
void | sourceAxisChanged(Qt3DInput::QAxis *sourceAxis)
void | sourceAxisTypeChanged(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)
void | valueChanged(float value)
void | velocityChanged(float value)

## Detailed Description

Constructs a new QAxisAccumulator instance with parent.

A Qt3DInput::QAxis reports the current position of an axis on an input device. When the axis is returned to its neutral position the value of that axis returns to 0. Often, it is required to have the input from an axis control a variable in other ways, for example treating the value from the Qt3DInput::QAxis as a velocity (first derivative with respect to time) or as an acceleration (second derivative with respect to time). This can be done with user code or with a Qt3DLogic::QFrameAction but those approached are not ideal as they add more work to the main thread and are inherently imperative. The Qt3DInput::QAxisAccumulator class allows for this common task to be performed on the Qt 3D backend and be specified in a declarative manner.

## Member Type Documentation

### enum QAxisAccumulator::SourceAxisType

Constant | Value
--- | ---
`Qt3DInput::QAxisAccumulator::Velocity` | `0`
`Qt3DInput::QAxisAccumulator::Acceleration` | `1`

## Property Documentation

### scale : float

Holds the amount to scale the axis value by when accumulating. This can be thought of as the maximum velocity or acceleration the axis can control.

Access functions:

float | scale() const
void | setScale(float scale)

Notifier signal:

void | scaleChanged(float scale)

### sourceAxis : Qt3DInput::QAxis*

Holds the QAxis for which the accumulator should integrate axis values.

Access functions:

Qt3DInput::QAxis * | sourceAxis() const
void | setSourceAxis(Qt3DInput::QAxis *sourceAxis)

Notifier signal:

void | sourceAxisChanged(Qt3DInput::QAxis *sourceAxis)

### sourceAxisType : SourceAxisType

Holds the type that specifies how the accumulator treats the values from the source axis.

Access functions:

Qt3DInput::QAxisAccumulator::SourceAxisType | sourceAxisType() const
void | setSourceAxisType(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

Notifier signal:

void | sourceAxisTypeChanged(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

### `[read-only]` value : float

Returns the accumulated (integrated) value.

Access functions:

float | value() const

Notifier signal:

void | valueChanged(float value)

### `[read-only]` velocity : float

Holds the velocity.

If the sourceAxisType is set to Velocity this is simply the value of the source axis multiplied by the scale. If the sourceAxisType is set to Acceleration, the velocity is integrated using the source axis' value as an acceleration.

Access functions:

float | velocity() const

Notifier signal:

void | velocityChanged(float value)

## Member Function Documentation

### QAxisAccumulator::QAxisAccumulator(Qt3DCore::QNode *parent = nullptr)

Constructs a new QAxisAccumulator instance with parent parent.

### float QAxisAccumulator::scale() const

The amount to scale the axis value by when accumulating. This can be thought of as the maximum velocity or acceleration the axis can control.

Returns the amount the input axis values are scaled by.

Note: Getter function for property scale.

See also setScale().

### `[slot]` void QAxisAccumulator::setSourceAxis(Qt3DInput::QAxis *sourceAxis)

Sets the source axis from which the accumulator should receive values from to sourceAxis. How these values are treated is controlled by the sourceAxisType and scale properties.

Note: Setter function for property sourceAxis.

See also sourceAxis().

### `[slot]` void QAxisAccumulator::setSourceAxisType(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

Sets how the accumulator treats the values originating from the sourceAxisType.

Note: Setter function for property sourceAxisType.

See also sourceAxisType().

### Qt3DInput::QAxis *QAxisAccumulator::sourceAxis() const

Returns QAxis for which the accumulator should integrate axis values.

Note: Getter function for property sourceAxis.

See also setSourceAxis().

### Qt3DInput::QAxisAccumulator::SourceAxisType QAxisAccumulator::sourceAxisType() const

Returns how the accumulator treats the value of the sourceAxis.

Note: Getter function for property sourceAxisType.

See also setSourceAxisType().

### float QAxisAccumulator::velocity() const

Returns the velocity. If the sourceAxisType is set to Velocity this is simply the value of the source axis multiplied by the scale. If the sourceAxisType is set to Acceleration, the velocity is integrated using the source axis' value as an acceleration.

Note: Getter function for property velocity.