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));
    		}
    	
    	}
    }
    

  • Moderators

    @pauledd
    connect to the QCamera::statusChanged() signal and only do your filling when the status changed to QCamera::LoadedStatus.
    So move your if(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().


  • Moderators

    @pauledd
    of course you should still check in the slot if the status changed to QCamera::LoadedStatus



  • alright, I'll try that, thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.