Qt Multimedia 的注意事项
本页讨论在 Windows 上使用Qt Multimedia 的注意事项。
COM 注意事项
Qt Multimedia 使用 Windows 平台的 COM API。这就要求在访问 API 的线程上初始化 COM。虽然 API 会根据需要自动初始化 COM,但我们建议在调用 API 之前,先在应用程序启动期间从主线程初始化 实例。这样可以确保在从任何线程调用 API 之前初始化主单线程公寓(主 STA)。这也保证了在所有其他公寓关闭之前,主 STA 不会被取消初始化。Qt Multimedia Qt Multimedia Qt Multimedia QGuiApplication Qt Multimedia
Qt Multimedia 需要 COM 的 API 会通过调用 将线程初始化为单线程公寓,并且直到线程退出才会调用 。这也适用于主程序线程,在销毁静态变量时会调用 。CoInitializeEx(nullptr, COINIT_APARTMENT_THREADED)
CoUninitialize
CoUninitialize
© 2025 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.