Accessing the camera

To access the camera when it is supported by the hardware and Qt Multimedia, use the Camera type and its associated types to control the camera's capture behavior, exposure, flash, focus, and image processing settings. A simple use of the camera to show a viewfinder is done with the following code:

import QtQuick 2.12import QtQuick.Window 2.12import QtMultimedia 5.12Window {    visible: true    width: 640    height: 480    title: qsTr("Webcam")    Item {        width: 640        height: 480        Camera {            id: camera        }        VideoOutput {            source: camera            anchors.fill: parent        }    }}

The preceding code produces the following result:

In short, the Camera type acts ...

Get Application Development with Qt Creator now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.