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

Native Development

Reply
Highlighted
Developer
Posts: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

[HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

[ Edited ]

I really don't have an idea what happened to my source code. All of a sudden I now cannot access the context property of my c++ code.

 

applicationui.cpp

 

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("app", this);
AbstractPane *root = qml->createRootObject<AbstractPane>();

 

and the function I am calling is

 

void ApplicationUI::test()
{
	qDebug() << "TESTING";
}

qDebug() works really fine so it should print if it really gets to this function.

 

applicationui.hpp

 

Q_INVOKABLE void test();

 

main.qml

 

onCreationCompleted: 
{
     app.test();
}

 

and the error I am getting when the function app.test() is called

 

asset:///main.qml:151: ReferenceError: Can't find variable: app

 

before it does really work. now it does not. any suggestions please?

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: [HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

Have you tried cleaning the project and rebuilding it again?

______________________________________________________
BB10-OAuth: GitHub
Developer
Posts: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: [HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

yup I tried and it even messed up more. it deleted the arm stuffs and cannot build anymore. I decided to create a new project and put back everything and went fine.

 

Thanks bro

New Contributor
Posts: 8
Registered: ‎08-13-2013
My Device: Blackberry Q10
My Carrier: Winjit Technologies Pvt. Ltd

Re: [HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

I also facing same issue and my project is a mid level, I can't create new one for that only.

 

Please anyone tell me if having some good solution.

 

Thanks in Advance.

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: [HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

creating a new project is the easiest solution.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
Posts: 8
Registered: ‎08-13-2013
My Device: Blackberry Q10
My Carrier: Winjit Technologies Pvt. Ltd

Re: [HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

[ Edited ]

But in my project it containing 15+ qml files and 10+ cpp files so I wouldn't take anymore risk... as I am new in BB 10.

 

Please suggest me any alternative solution.

 

I always welcome of your any type of feedback.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: [HELP] asset:///main.qml:151: ReferenceError: Can't find variable: app

I did a quick test as the first thing that struck me was that this may be similar to something that happened to me a few months back when a new keyword was added overriding my own.

 

However I've tested using 'app' and it works fine for me on 10.2.

 

Can I suggest changing it to '_app' or adding a new variable just to test if it's actually being passed through?

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.