Qt 6 是努力使框架更高效,且更易於使用的結果。
為兼容每個發行的所有公共 API,我們試著維護二進製和源代碼。但是,為使 Qt 成為更優框架,一些改變是不可避免的。
模塊已顯著重構且更改瞭分類,從必需到附件。Qt 6 中的 Qt Multimedia 模塊替換來自 Qt 5.x 的 Qt Multimedia 模塊。使用來自 Qt 5 的 Qt Multimedia 的現有代碼,通過有限努力可以移植。
Qt Multimedia 有許多新特徵:
| 移除特徵 | 注意事項或建議替代 |
|---|---|
| 播放列錶在 QMediaPlayer | QMediaPlayer 在 Qt 6 不再對播放列錶做任何處理。 |
| QMediaPlayList | This class has been removed from the API. It does however still exist as part of the 媒體播放器範例 . |
| QAudioProbe 和 QVideoProbe | 已移除音頻和視頻探測 API。 |
| QAudioRecorder | 使用 QMediaCaptureSession or CaptureSession QML 類型。 |
| 音頻 QML 類型 | 使用 MediaPlayer QML 類型。 |
| QMediaObject 和 QMediaBindableInterface | These classes have been removed in favor of a more direct API for setting up connections between objects using, for example, setVideoOutput and QMediaCaptureSession . |
| QCameraViewFinderSettings | This class has been removed. Use QCameraFormat to define the resolution and frame rate the camera should be using. |
| QMediaContent | 類已被移除。使用 QUrl for individual media files instead. |
| QSound | 使用 QSoundEffect 代替。 |
| QVideoFilterRunnable | 使用 著色器效果 in QML instead or access the QVideoFrame 's content in C++. |
| 公共後端 API | The back-end API of Qt Multimedia is private in Qt 6. This improves response time for supporting new multimedia use cases. Any classes that contain the words "Control" or "Abstract" in the class name in Qt 5 are now private in Qt 6. |
| Support for ALSA audio on Linux is experimental | Audio on Linux requires PulseAudio. Experimental ALSA support will be deprecated in future Qt versions. See Linux platform notes 瞭解細節。 |
A number of classes previously offered in Qt Multimedia have changed in ways that may affect previously written code. The following table highlights these changes.
| 變化特徵 | 注意事項 |
|---|---|
| 攝像頭分辨率和幀速率的處理 | Handling of these has been simplified and a new QCameraFormat class helps with selecting the correct resolution and frame rate for the camera. |
| Video output handling on the C++ side has changed significantly. | QAbstractVideoSurface has been replaced by the QVideoSink class, and generic rendering support has been enhanced to cover all 像素格式 s supported by Qt Multimedia. |
| 元數據類型 | QMediaMetaData has changed significantly: mainly moving from string based to enum based keys, and reducing the set of supported keys to the ones that can be supported on most platforms. |
| QMediaFormat | Handling of formats for encoded media and the settings for the media recorder have changed significantly. Qt 5 provides a string-based API, a separated file format, and audio and video codecs into three classes. However, Qt 6 unifies the formats in the QMediaFormat class. Additional settings are directly specified in QMediaRecorder . Setting up file formats and codecs is now implemented with enums and no longer uses strings. This puts some limitations on the set of codecs that can be used, but helps provide a consistent cross-platform API. |
| QCameraImageCapture 重命名 QImageCapture | None |
| 音頻輸入和輸齣 | QMediaPlayer and QMediaCaptureSession (and the corresponding QML types MediaPlayer and CaptureSession ) are not connected to any audio devices by default. Explicitly connect them to a QAudioInput / AudioInput or QAudioOutput / AudioOutput 以捕獲 (或迴放) 音頻。 |
| 捕獲視頻 | A capture session is by default not connected to a Camera. Connect it to a QCamera object (Camera item) to be able to capture video or still images. |