QVoice Class

The QVoice class represents a particular voice. More...

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

Public Types

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

Properties

Public Functions

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

Static Public Members

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

Detailed Description

To get a voice that is supported by the current text-to-speech engine, use QTextToSpeech::availableVoices().

Member Type Documentation

enum QVoice::Age

The age of a voice.

ConstantValueDescription
QVoice::Child0Voice of a child
QVoice::Teenager1Voice of a teenager
QVoice::Adult2Voice of an adult
QVoice::Senior3Voice of a senior
QVoice::Other4Voice of unknown age

enum QVoice::Gender

The gender of a voice.

ConstantValueDescription
QVoice::Male0Voice of a male
QVoice::Female1Voice of a female
QVoice::Unknown2Voice of unknown gender

Property Documentation

[read-only] age : const Age

This property holds the age of a voice

Access functions:

QVoice::Age age() const

[read-only] gender : const Gender

This property holds the gender of a voice

Access functions:

QVoice::Gender gender() const

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

This property holds the locale of the voice

The locale includes the language and the territory (i.e. accent or dialect) of the voice.

This property was introduced in Qt 6.4.

Access functions:

QLocale locale() const

[read-only] name : const QString

This property holds the name of a voice

Access functions:

QString name() const

Member Function Documentation

QVoice::QVoice(QVoice &&other)

Constructs a QVoice object by moving from other.

QVoice::QVoice(const QVoice &other)

Copy-constructs a QVoice from other.

QVoice::QVoice()

Constructs an empty QVoice.

QVoice &QVoice::operator=(QVoice &&other)

Moves other into this QVoice object.

QVoice &QVoice::operator=(const QVoice &other)

Assigns other to this QVoice object.

QVoice::~QVoice()

Destroys the QVoice instance.

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

Returns a string representing the age class of a voice.

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

̈́ Returns the gender name of a voice.

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

Swaps other with this voice. This operation is very fast and never fails.

This function was introduced in Qt 6.4.

Related Non-Members

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

Returns whether the lhs voice and the rhs voice are different.

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

Serializes voice to data stream stream.

This function was introduced in Qt 6.4.

See also Serializing Qt Data Types.

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

Writes information about voice to the debug stream.

This function was introduced in Qt 6.4.

See also QDebug.

bool operator==(const QVoice &lhs, const QVoice &rhs)

Returns whether the lhs voice and the rhs voice are identical.

Two voices are identical if name, locale, gender, and age are identical, and if they belong to the same text-to-speech engine.

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

Deserializes voice from data stream stream.

This function was introduced in Qt 6.4.

See also Serializing Qt Data Types.

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