本页内容

QAudioListener Class

定义了聆听由QAudioEngine 定义的声场的人的位置和方向。更多内容...

标题: #include <QAudioListener>
CMake: find_package(Qt6 REQUIRED COMPONENTS SpatialAudio)
target_link_libraries(mytarget PRIVATE Qt6::SpatialAudio)
qmake: QT += spatialaudio
继承自: QObject

公共函数

QAudioListener(QAudioEngine *engine)
virtual ~QAudioListener() override
QAudioEngine *engine() const
QVector3D position() const
QQuaternion rotation() const
void setPosition(QVector3D pos)
void setRotation(const QQuaternion &q)

详细说明

一个QAudioEngine 可以拥有且仅有一个监听器,该监听器定义了监听声场的人的位置和朝向。

成员函数文档

[explicit] QAudioListener::QAudioListener(QAudioEngine *engine)

为engine 的空间音频引擎创建一个监听器。

注意: 调用时必须 传入一个有效的QAudioEngine

[override virtual noexcept] QAudioListener::~QAudioListener()

销毁监听器。

QAudioEngine *QAudioListener::engine() const

返回与该监听器关联的引擎。

QVector3D QAudioListener::position() const

返回监听器的当前位置。

另请参阅 setPosition()。

QQuaternion QAudioListener::rotation() const

返回监听器在三维空间中的朝向。

另请参阅 setRotation()。

void QAudioListener::setPosition(QVector3D pos)

将听众在3D空间中的位置设置为pos 。默认单位为厘米。

另请参阅 position() 和QAudioEngine::distanceScale 。

void QAudioListener::setRotation(const QQuaternion &q)

将观察者在3D空间中的朝向设置为q 。

另请参阅 rotation()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.