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.
  • P Offline
    P Offline
    pauledd
    wrote on 8 Sept 2016, 07:38 last edited by pauledd 9 Aug 2016, 07:38
    #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));
    		}
    	
    	}
    }
    
    R 1 Reply Last reply 8 Sept 2016, 07:48
    0
    • P pauledd
      8 Sept 2016, 07:38

      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));
      		}
      	
      	}
      }
      
      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 8 Sept 2016, 07:48 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

      P 1 Reply Last reply 8 Sept 2016, 07:59
      1
      • R raven-worx
        8 Sept 2016, 07:48

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

        P Offline
        P Offline
        pauledd
        wrote on 8 Sept 2016, 07:59 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().

        R 1 Reply Last reply 8 Sept 2016, 08:03
        0
        • P pauledd
          8 Sept 2016, 07:59

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

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 8 Sept 2016, 08:03 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
          • P Offline
            P Offline
            pauledd
            wrote on 8 Sept 2016, 08:04 last edited by
            #5

            alright, I'll try that, thanks.

            1 Reply Last reply
            0

            4/5

            8 Sept 2016, 08:03

            • Login

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