QVoice Class

QVoice 类代表一个特定的语音。更多

头文件: #include <QVoice>
CMake: find_package(Qt6 REQUIRED COMPONENTS TextToSpeech)
target_link_libraries(mytarget PRIVATE Qt6::TextToSpeech)
qmake: QT += texttospeech

公共类型

enum Age { Child, Teenager, Adult, Senior, Other }
enum Gender { Male, Female, Unknown }

属性

  • age : const Age
  • gender : const Gender
  • (since 6.6) language : const QLocale::Language
  • (since 6.4) locale : const QLocale
  • name : const QString

公共函数

QVoice()
QVoice(const QVoice &other)
QVoice(QVoice &&other)
~QVoice()
QVoice::Age age() const
QVoice::Gender gender() const
QLocale::Language language() const
QLocale locale() const
QString name() const
(since 6.4) void swap(QVoice &other)
QVoice &operator=(QVoice &&other)
QVoice &operator=(const QVoice &other)

静态公共成员

QString ageName(QVoice::Age age)
QString genderName(QVoice::Gender gender)
bool operator!=(const QVoice &lhs, const QVoice &rhs)
(since 6.4) QDataStream &operator<<(QDataStream &stream, const QVoice &voice)
(since 6.4) QDebug operator<<(QDebug debug, const QVoice &voice)
bool operator==(const QVoice &lhs, const QVoice &rhs)
(since 6.4) QDataStream &operator>>(QDataStream &stream, QVoice &voice)

详细说明

要获取当前文本到语音引擎支持的语音,请使用QTextToSpeech::availableVoices() 或QTextToSpeech::findVoices() 。

成员类型文档

enum QVoice::Age

声音的时代

恒定说明
QVoice::Child0儿童的声音
QVoice::Teenager1青少年的声音
QVoice::Adult2成人的声音
QVoice::Senior3老年人的声音
QVoice::Other4未知年龄的声音

enum QVoice::Gender

声音的性别

常数说明
QVoice::Male0男声
QVoice::Female1女声
QVoice::Unknown2性别未知的声音

属性文件

[read-only] age : const Age

该属性保存语音的年龄

访问功能:

QVoice::Age age() const

[read-only] gender : const Gender

该属性用于保存语音的性别

访问功能

QVoice::Gender gender() const

[read-only, since 6.6] language : const QLocale::Language

该属性包含语音的语言

这是语音localelanguage 属性。

该属性在 Qt 6.6 中引入。

访问功能:

QLocale::Language language() const

[read-only, since 6.4] locale : const QLocale

该属性包含语音的地域

locale 包括语音的语言和地域(即口音或方言)。

该属性在 Qt 6.4 中引入。

访问函数:

QLocale locale() const

[read-only] name : const QString

该属性用于保存语音名称

访问功能:

QString name() const

成员函数文档

QVoice::QVoice()

构造一个空 QVoice。

应用程序代码不能构建任意语音实例。请使用QTextToSpeech::availableVoices() 或QTextToSpeech::findVoices() 选择支持的语音。

[noexcept] QVoice::QVoice(const QVoice &other)

other 复制-构建 QVoice。

[noexcept] QVoice::QVoice(QVoice &&other)

other 开始构建 QVoice 对象。

[noexcept] QVoice::~QVoice()

销毁QVoice 实例。

[static] QString QVoice::ageName(QVoice::Age age)

返回表示语音age 类别的字符串。

[static] QString QVoice::genderName(QVoice::Gender gender)

̈́ 返回gender 语音名称。

[noexcept, since 6.4] void QVoice::swap(QVoice &other)

与该语音交换other 。该操作速度非常快,而且从不出错。

此功能在 Qt 6.4 中引入。

[noexcept] QVoice &QVoice::operator=(QVoice &&other)

other 移入此QVoice 对象。

[noexcept] QVoice &QVoice::operator=(const QVoice &other)

QVoice 对象指定other

相关非会员

[noexcept] bool operator!=(const QVoice &lhs, const QVoice &rhs)

返回lhs 声音和rhs 声音是否不同。

[since 6.4] QDataStream &operator<<(QDataStream &stream, const QVoice &voice)

voice 序列化为数据流stream

此函数在 Qt 6.4 中引入。

另请参阅 序列化 Qt 数据类型

[since 6.4] QDebug operator<<(QDebug debug, const QVoice &voice)

将有关voice 的信息写入debug 流。

此函数在 Qt 6.4 中引入。

另请参阅 QDebug

[noexcept] bool operator==(const QVoice &lhs, const QVoice &rhs)

返回lhs 语音和rhs 语音是否相同。

如果name,locale,gender, 和age 相同,并且属于同一个文本到语音引擎,则这两个语音是相同的。

[since 6.4] QDataStream &operator>>(QDataStream &stream, QVoice &voice)

从数据流stream 反序列化voice

该函数在 Qt 6.4 中引入。

另请参阅 序列化 Qt 数据类型

© 2025 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.