Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to wait for QCamera::load() ?
QtWS25 Last Chance

how to wait for QCamera::load() ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qcameraloadwait
5 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • pauleddP Offline
    pauleddP Offline
    pauledd
    wrote on last edited by pauledd
    #1

    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));
    		}
    	
    	}
    }
    
    raven-worxR 1 Reply Last reply
    0
    • pauleddP pauledd

      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));
      		}
      	
      	}
      }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      pauleddP 1 Reply Last reply
      1
      • raven-worxR raven-worx

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

        pauleddP Offline
        pauleddP Offline
        pauledd
        wrote on last edited by
        #3

        @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().

        raven-worxR 1 Reply Last reply
        0
        • pauleddP pauledd

          @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().

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

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

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • pauleddP Offline
            pauleddP Offline
            pauledd
            wrote on last edited by
            #5

            alright, I'll try that, thanks.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved