Title summarizes my question. I'm using Qt 5.15 in MinGW, gcc 10.2, C++17.

I have a UI with a QVideoWidget with video output to a QMediaPlayer. The UI layout/size automatically rescales to the loaded media, i.e. it depends on the size of that media.
Because of this, I need to finish loading the media set with QMediaPlayer::setMedia(.. to avoid unneccessary layout/resize calls.
However QMediaPlayer::setMedia(.. returns immediately and I can only check if loading is finished by inspecting QMediaPlayer::MediaStatus with the appropriate slot.

Currently, on my load call, I put all size-dependent arguments in a buffer struct and then call the actual layout/resize function either if loading is already finished, or whenever
Qt Code:
  1. QMediaPlayer::MediaStatus == QMediaPlayer::LoadedMedia
To copy to clipboard, switch view to plain text mode 
But this a bit messy and still means I have to return from my loading function possibly before loading is finished, thus doing all layout/resizing twice..

So: is there any way to specifically wait for loading of the media to finish after calling QMediaPlayer::setMedia(..? As far as I understand, everything is handled by events, not threads, so doing something like
Qt Code:
  1. while(!loaded){}
To copy to clipboard, switch view to plain text mode 
would simply lock forever. Do I need to somehow request for a specific event to be processed immediately? Or do I call QMediaPlayer::setMedia(.. itself on a new thread and then lock the main thread with a mutex, would this be defined behavior to do in Qt? Or something else entirely?