how to wait for QCamera::load() ?
-
Hi there,
I have a function that reqests the supported pixelformats from a camera and fills a QComboBox with the results.
But before I can do that the camera needs to be loaded. How can I call "camera->load();" and then wait or check for it to be loaded and only then check for the formats. If I check immediately after load() for the formats it will fail because it seems to need some time to communicate with the camera:void MainWindow::getCameraFormat(){ camera->load(); // Will fail if(camera->status() == QCamera::LoadedStatus) { qDebug()<< "camera loaded, filling supported formats"; foreach (QVideoFrame::PixelFormat fmt, camera->supportedViewfinderPixelFormats()) { comboBoxFormats->addItem(convertToString(fmt),QVariant::fromValue<int>(fmt)); } } }
-
@pauledd
connect to theQCamera::statusChanged()
signal and only do your filling when the status changed to QCamera::LoadedStatus.
So move yourif(camera->status() == QCamera::LoadedStatus)
block to the slot. -
@raven-worx but the problem I see is that the slot then will be called also everytime when I start my camera because it also calles cameraQCamera::statusChanged().
-
@pauledd
of course you should still check in the slot if the status changed toQCamera::LoadedStatus