title: Enable / disable camera (QML Camera)
body: <p>I have qml camera widget in camera.qml.  the qml component is loaded from a Qt widget "WidgetCamera" that is placed on a stack widget in the background. The widget starts the camera device already at creation.</p>
  
  <p>How to make the camera start only when the widget is shown in the foreground. And vice versa, how release the camera when the widget goes to the background?</p>
  
  <p>camera.qml</p>
  
  <pre><code>Item {
      width: 640
      height: 360
  
      Camera {
          id: camera
      }
  
      VideoOutput {
          source: camera
          anchors.fill: parent
      }
  }
  </code></pre>
  
  <p>widgetCamera.h</p>
  
  <pre><code>class WidgetCamera : public QWidget
  {
      Q_OBJECT
      public:
      WidgetCamera() {
         QQuickWidget *qw= new QQuickWidget;
         qw-&gt;setSource(QUrl("qrc:///camera.qml"));
         // ...
      }
  }
  </code></pre>
  
  <p>mainwindow.h</p>
  
  <pre><code>class MainWindow : QMainWindow
  {
      Q_OBJECT
      public:
      MainWindow() {
      QStackedWidget *sw = new QStackedWidget;
      sw-&gt;addWidget(new QWidget());
      sw-&gt;addWidget(new WidgetCamera());
  
      // ...
  
      }
  }
  </code></pre>