Changes to Qt TextToSpeech

Qt 6 是努力使框架更高效,且更易於使用的結果。

為兼容每個發行的所有公共 API,我們試著維護二進製和源代碼。但是,為使 Qt 成為更優框架,一些改變是不可避免的。

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 can now receive additional configuration parameters. When constructing a QTextToSpeech instance, pass a QVariantMap with engine-specific key/value pairs.

API 變化

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 枚舉值 BackendError has been renamed to Error . Detailed error information is available via QTextToSpeech::errorReason () 和 QTextToSpeech::errorString ().

新的 engine property allows changing of the engine on an initialized QTextToSpeech 對象。

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.