summaryrefslogtreecommitdiffstats
path: root/src/multimediawidgets/doc/snippets/multimedia-snippets/camera.cpp
blob: a92c51e69da043e1b7380158f1df3ad0fe9665d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

// Camera snippets
// Extracted from src/multimedia/doc/snippets/multimedia-snippets/camera.cpp
#include "qcamera.h"
#include "qvideowidget.h"
#include "qimagecapture.h"

/* Globals so that everything is consistent. */
QCamera *camera = 0;
QImageCapture *imageCapture = 0;
QVideoWidget *viewfinder = 0;

void camera_blah()
{
    //! [Camera]
    QMediaCaptureSession captureSession;
    camera = new QCamera;
    captureSession.setCamera(camera);

    viewfinder = new QVideoWidget();
    viewfinder->show();
    captureSession.setVideoOutput(viewfinder);

    imageCapture = new QImageCapture;
    captureSession.setImageCapture(imageCapture);

    camera->start();
    //! [Camera]

    //! [Camera keys]
    //on shutter button pressed
    imageCapture->capture();
    //! [Camera keys]
}