Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus
Accepted Solution

issue getting cameraView to show

I'm trying to get the cameraView to show but when I open the sheet it just shows the underlying page.  What's funny though, is that the camera takes pictures when I touch.


This is the code for my camera QML:


I'm calling this QML from a sheet, don't know if that makes a difference.  Is there no standard QML code for getting the basic cameraview (like in the camera app) without having to invoke the camera?  I want to reference the saved images back in my app.


import bb.cascades 1.0
import bb.cascades.multimedia 1.0
import bb.multimedia 1.0

Sheet {
    id: cameraSheet
Page {
    id: photoPage
    titleBar: TitleBar {
        title: qsTr("Take a picture") + Retranslate.onLanguageChanged
        dismissAction: ActionItem {
            title: qsTr("Cancel") + Retranslate.onLanguageChanged
            onTriggered: {
                // Hide the Sheet.
    // A Container is used to gather visual items together.
    Container {
        layout: DockLayout {
        Container {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill
            // This is the camera control that is defined in the cascades multimedia library.
            Camera {
                id: camera
                onTouch: {
                    if (event.isDown()) {
                        // Take photo
                // When the camera is opened we want to start the viewfinder
                onCameraOpened: {
                    // Using helper function to set resolution
                    // Additional camera settings, setting focus mode and stabilization
                    cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
                    cameraSettings.shootingMode = CameraShootingMode.Stabilization
//                    camera.startViewfinder();
                // There are loads of messages we could listen to here.
                // onPhotoSaved and onShutterFired are taken care of in the C++ code.
                onCameraOpenFailed: {
                    console.log("onCameraOpenFailed signal received with error " + error);
                onViewfinderStartFailed: {
                    console.log("viewfinderStartFailed signal received with error " + error);
                onViewfinderStopFailed: {
                    console.log("viewfinderStopFailed signal received with error " + error);
                onPhotoCaptureFailed: {
                    console.log("photoCaptureFailed signal received with error " + error);
                onPhotoSaveFailed: {
                    console.log("photoSaveFailed signal received with error " + error);
                onPhotoSaved: {
                    setting.lastFileName = fileName;
                    // Makes the ImageButton visible when a photo is captured.
                    setting.visible = true;
                onShutterFired: {
                    // A cool trick here to play a sound. There are legal requirements in many countries to have a shutter-sound when
                    // taking pictures. So we need this shutter sound if you are planning to submit you're app to app world.
                    // So we play the shutter-fire sound when the onShutterFired event occurs.
                onCameraResourceAvailable: {
                    // This signal handler is triggered when the Camera resource becomes available to app
                    // after being lost by for example putting the phone to sleep, once it has been received
                    // it is possible to start the viewfinder again. 
                onCreationCompleted: {
                    // Open the front facing camera.
                attachedObjects: [
                    CameraSettings {
                        id: cameraSettings
                    SystemSound {
                        id: cameraSound
                        sound: SystemSound.CameraShutterEvent

    } // content Container
}// Page

 Thanks in davnce.  All help will be liked and solutions will be marked.



Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: issue getting cameraView to show

Nevermind,  I found a way easier way to do this just by invoking the camera using C++


bb::system::InvokeManager manager;
bb::system::InvokeRequest request;
request.setAction("bb.action.CAPTURE ");
InvokeTargetReply *targetReply = manager.invoke(request);