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. |
后端插件 | Qt Multimedia in Qt 6 does not use a plugin infrastructure for its back ends anymore. This means that users no longer need to ship those back ends with their application. Instead, the back end being used is determined at compile time based on the underlying operating system. Qt uses gstreamer on Linux, WMF on Windows, AVFoundation on macOS and iOS and the Android multimedia APIs on Android. |
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. |