QAudioOutput Class
表示一个音频输出通道。更多...
| 标题: | #include <QAudioOutput> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Multimedia) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
| qmake: | QT += multimedia |
| 在 QML 中: | AudioOutput |
| 继承自: | QObject |
属性
公共函数
公共槽位
信号
| void | deviceChanged() |
| void | mutedChanged(bool muted) |
| void | volumeChanged(float volume) |
详细说明
该类表示一个输出通道,可与QMediaPlayer 或QMediaCaptureSession 配合使用。它支持选择要使用的物理输出设备、静音该通道以及调节通道音量。
注意:在 WebAssembly 平台上,由于其异步特性,当音频输出列表准备就绪时,会触发QMediaDevices::audioOutputsChanged() 信号。此操作需要用户权限,且仅在安全的 https 上下文中有效。
另请参阅 QAudioInput 。
属性文档
device : QAudioDevice
该属性存储了连接到此输出的音频设备。
device属性表示该输出连接的音频设备。该属性可用于从QMediaDevices::audioOutputs 列表中选择输出设备。您可以通过将该属性设置为默认构造的QAudioDevice 对象来选择系统默认音频输出。
访问函数:
| QAudioDevice | device() const |
| void | setDevice(const QAudioDevice &device) |
通知信号:
| void | deviceChanged() |
muted : bool
该属性存储当前媒体的静音状态。
如果输出被静音,该值将为true ;否则为false 。
访问函数:
| bool | isMuted() const |
| void | setMuted(bool muted) |
通知信号:
| void | mutedChanged(bool muted) |
volume : float
该属性存储当前音量值。
音量按线性比例调整,范围从0 (静音)到1 (最大音量)。
注意: 超出此范围的值 将被限制。
默认情况下,音量为1 。
UI 音量控件通常应采用非线性缩放。例如,使用对数刻度会产生感知响度的线性变化,这正是用户通常对音量控件的期望。
访问函数:
| float | volume() const |
| void | setVolume(float volume) |
通知信号:
| void | volumeChanged(float volume) |
另请参阅 QtAudio::convertVolume()。
© 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.