Tutorial: Create a photo app

The ability to take photos directly from your app can create an enhanced user experience. Rather than exiting or suspending your app to open the default Camera app and take a photo, you can add this photo functionality to your app so your users can take a photo directly from within your app. For example, if you created a contacts app and you wanted your users to be able to add a photo of a contact, that photo could be taken and added to their contacts list from within your app. This makes your app more interactive and useful.

This tutorial will show you how to create a photo app that lets you take a photo and save it on the device.

You will learn to:

  • Set up a project
  • Trigger photo capture
  • Post-process viewfinder frames
  • Set camera properties
Screen shot of camera photo sample app

Set up your app

Setting up an app is pretty similar whether we're using QML or C++ to do it. For more information on how to set up your app in both ways, see Set up your project.

Before you begin

Taking a photo with your camera app starts by opening a camera and starting the viewfinder. Before your app can open a camera unit, you must define a Camera control in your app's main.qml file. Within your Camera control definition, you must also define a SystemSound object, and a CameraSettings object. If you're not using C++ to define these objects, then they're put within the QML camera control definition as attached objects.

Creating a Camera control, attaching objects to it, and then adding the Camera control to your root Container can all be done programmatically using only C++ code. However, developers typically choose to build their UI using QML as shown here.

The SystemSound object is needed to play the required camera shutter sound when your app takes a photo.

The CameraSettings object is needed to set the CameraMode property of the Camera control to Photo.

For more information on how to set Camera properties, see Set photo properties.

For more information about the Camera properties available, see CameraSettings.

Last modified: 2014-03-27



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus