Welcome!

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

Web and WebWorks Development

Reply
Contributor
abhisardeshmukh
Posts: 12
Registered: ‎05-26-2010
My Device: Dev Alpha
My Carrier: Airtel

Is it possible to use .qml in Shared Library for webworks extension for BB10 dev alpha

Hi All,

 

I want to create Shared Library for webworks extension for BB10 dev alpha.

https://developer.blackberry.com/html5/documentation/creating_extensions_for_bb10_apps.html

 

I am tring to Load UI description from main.qml which contains camera code for scanning

 

my  main. qml is 

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

Page {
    id: page

    Container {
        background: Color.Black

        layout: DockLayout {}

//! [0]
        // The camera preview control
        Camera {
            id: camera

            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill
            

            onCameraOpened: {
                // Apply some settings after the camera was opened successfully
                getSettings(cameraSettings)
                cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
                cameraSettings.shootingMode = CameraShootingMode.Stabilization                
                applySettings(cameraSettings)

                // Start the view finder as it is needed by the barcode detector
                camera.startViewfinder()
            }

            onViewfinderStarted: {                
                // Setup the barcode detector with the camera object now
                barcodeDetector.camera = camera
                barcodeDetector.formats = BarcodeFormat.Any
            }

            attachedObjects: [
                CameraSettings {
                    id: cameraSettings
                }                
            ]
        }
        
//! [0]

        // The overlay image
        ImageView {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill

            imageSource: "asset:///images/overlay.png"
        }

        // The area at the top that shows the results
        Container {
            id: resultArea

            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Top

            layout: DockLayout {}

            visible: false

            ImageView {
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill

                imageSource: "asset:///images/result_background.png"
            }

            Label {
                id: resultLabel

                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Center

                textStyle {
                    base: SystemDefaults.TextStyles.TitleText
                    color: Color.White
                    textAlign: TextAlign.Center
                }

                multiline: true
            }
        }

        // The upper cover image
        ImageView {
            id: topCover

            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Top

            imageSource: "asset:///images/top_cover.png"

            onTouch: {
                if (event.isDown())
                    startupAnimation.play()
            }
        }

        // The lower cover image
        ImageView {
            id: bottomCover

            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Bottom

            imageSource: "asset:///images/bottom_cover.png"

            onTouch: {
                if (event.isDown())
                    startupAnimation.play()
            }
        }

        // The startup animation that slides out the cover images
        animations: ParallelAnimation {
            id: startupAnimation

            SequentialAnimation {
                target: topCover
                TranslateTransition {
                    fromY: 0
                    toY: -640
                    duration: 1250
                    easingCurve: StockCurve.QuarticInOut
                }
            }
            SequentialAnimation {
                target: bottomCover
                TranslateTransition {
                    fromY: 0
                    toY: 680
                    duration: 1250
                    easingCurve: StockCurve.QuarticInOut
                }
            }

//! [1]
            onStarted: {
                camera.open()
            }
//! [1]

            onEnded: {
                // Work around a bug temporarily
                camera.open()
            }
        }
    }

//! [2]
    attachedObjects: [
        BarcodeDetector {
            id: barcodeDetector
            
            /*cameraChanged: {
                setFormats(0xffff);
            }*/

            onBarcodeDetected: {
                if (resultLabel.text != data) {
                    resultLabel.text = data;
                    resultArea.visible = true;
                    scannedSound.play()
                }
            }
        },
        
        
        SystemSound {
            
            id: scannedSound
            sound: SystemSound.GeneralNotification
        }                
    ]
//! [2]
}

 

 

The code i am using in .cpp is 

 

string ScanBarcode::startScan() {
try{
// Load the UI description from main.qml
QmlDocument *qml = QmlDocument::create("asset:///main.qml");
// Create the application scene
AbstractPane *appPage = qml->createRootObject<AbstractPane>();
Application::instance()->setScene(appPage);
return Application::exec();
}catch (exception & e) {
return  "The exception occurs";
}
}

 

The application gets freeze. 

 

For simple hello world  qml also the application gets freeze. No exception thrown.:manfrustrated:

 

Waiting for reply. Thank in advance..... :Helpsmilie:

Please use plain text.