Capture from the Device Camera

With the QML Multimedia components, you can access and capture from the device camera.

View the Device Camera Output

This example uses the Camera component to simply view the device camera output.

 import VPlayApps 1.0
 import QtQuick 2.0
 import QtMultimedia 5.9

 App {

   // Displays a title bar and is used for navigation between pages
   NavigationStack {

     Page {
       title: "Camera"

       Camera {
         id: camera
       }

       VideoOutput {
         anchors.fill: parent
         source: camera
         autoOrientation: true
       }
     }
   }
 }

Capture Image from Device Camera

You can also use the Multimedia components components to capture images or videos from the camera. You can look at the CameraCapture components to find an example.

As a convenient alternative, V-Play also provides methods for this with the NativeUtils. This example opens the native camera dialog to take a picture.

 import VPlayApps 1.0
 import VPlay 2.0
 import QtQuick 2.9

 App {
   id: app

   NavigationStack {

     Page {

       AppImage {
         id: image
         anchors.fill: parent
         // important to automatically rotate the image taken from the camera
         autoTransform: true
         fillMode: Image.PreserveAspectFit
       }

       AppButton {
         anchors.centerIn: parent
         text: "Display CameraPicker"
         onClicked: {
           nativeUtils.displayCameraPicker("test")
         }
       }

       Connections {
         target: nativeUtils
         onCameraPickerFinished: {
           if(accepted) image.source = path
         }
       }
     }
   }
 }

Scan a QR Code with the Camera

For QR Code scanning, we recommend this library: https://github.com/ftylitak/qzxing

We also used it in this open-source example app: Qt World Summit Conference App

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support