Changes to Qt TextToSpeech

Qt 6 is a result of the conscious effort to make the framework more efficient and easy to use.

We try to maintain binary and source compatibility for all the public APIs in each release. But some changes were inevitable in an effort to make Qt a better framework.

In this topic we summarize those changes in Qt TextToSpeech, and provide guidance to handle them.

Available Engines

All engines that were available in Qt 5 are also available in Qt 6.4. For a complete list of available engines in Qt 6.4, see Qt TextToSpeech Engines.

Engines can now receive additional configuration parameters. When constructing a QTextToSpeech instance, pass a QVariantMap with engine-specific key/value pairs.

API changes

The Qt TextToSpeech module has undergone some basic consolidation and cleanup. There should be minimal porting effort to be able to switch to Qt 6.

The QTextToSpeech class

The QTextToSpeech::State enum value BackendError has been renamed to Error. Detailed error information is available via QTextToSpeech::errorReason() and QTextToSpeech::errorString().

The new engine property allows changing of the engine on an initialized QTextToSpeech object.

The pause and QTextToSpeech::stop slots take a QTextToSpeech::BoundaryHint enum value. This will break the compilation for signal/slot connections that use PMF syntax if the signal has parameters that were previously ignored:

connect(stopButton, &QPushButton, tts, &QTextToSpeech::stop);

Either connect to a signal without parameters, or use a lambda and call the respective slot method explicitly:

connect(stopButton, &QPushButton, tts, [tts]{ tts->stop(); });

The QVoice class

Existing code using the QVoice class continues to work as before. QVoice objects can now be serialized via QDataStream.

The QTextToSpeechEngine and QTextToSpeechPlugin classes

These classes have been removed from the public API. They still exist and are used by the available engine implementations, but they are not part of the documented and supported API, and are likely to change in future releases.

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