Qt Multimedia on Windows

This page discusses considerations for using Qt Multimedia on Windows.

Notes on COM

Qt Multimedia uses COM APIs from the Windows platform. This requires COM to be initialized on the threads that access Qt Multimedia APIs. Although Qt Multimedia APIs will automatically initialize COM as needed, we recommend initializing the QGuiApplication instance from the main thread during application startup before making any calls to Qt Multimedia APIs. This ensures that the main single threaded apartment (main STA) is initialized before Qt Multimedia APIs are called from any thread. This also guarantees that the main STA is not uninitialized until all other apartments have shut down.

Qt Multimedia APIs that require COM will initialize the thread as a single-threaded apartment by calling CoInitializeEx(nullptr, COINIT_APARTMENT_THREADED), and CoUninitialize will not be called until the thread exits. This applies to the main application thread as well, where CoUninitialize is called during the destruction of static variables.

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