QML camera

So far, we talked about how to access and control the camera in Qt/C++. Now it's time to see how QML does in this area. Although there are some limitations, you'll find it's much easier and more elegant to do this in Qt Quick/QML because of the many packages that Qt has to offer.

Create a new Qt Quick application project. The main.qml content is shown as follows:

import QtQuick 2.3 import QtQuick.Controls 1.2 import QtMultimedia 5.3 import "qrc:/" ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("QML Camera Demo") Camera { id: camera imageCapture { onImageCaptured: { photoPreview.source = preview photoPreview.visible = true; previewTimer.running = true; } } } VideoOutput { id: viewfinder source: camera anchors.fill: ...

Get Qt 5 Blueprints now with O’Reilly online learning.

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