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: 89
Registered: ‎10-18-2012
My Device: BB Z10
My Carrier: -

setContextProperty and ControlDelegate

Hi all,


I have a contextProperty declared in my project like this:


QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_app", this);

 and an invokable method:


    Q_INVOKABLE void showFavorites();


Inside main.qml I have a ControlDelegate:


Tab {
            title: qsTr("Settings")
            content:Page { 
        		    ControlDelegate {
    		            id: tab5
    		            source: "settings.qml"
    		            delegateActive: true       


The problem is that I can call to _app.showFavorites() inside main.qml without problems, but when I call it from settings.qml I get the next error:


ReferenceError: Can't find variable: _app


Is there any way to reference a context property from inside a ControlDelegate???

I know I can stop using the ControlDelegate, but I think it is less elegant and less readable.