O'Reilly logo

Qt 5 Blueprints by Symeon Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required