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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Contributor
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator
My Carrier: Me
Accepted Solution

Function call problems

Hi,

 

This Documention:

http://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html

discribes how to load in c++ a qml file and vise versa.

What I know so far is, that I can create a function in c++ like

<projectname>::myFunction() {
//Do calculation here
}
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); //this is where the qml //file is loaded
qml->setContextProperty("app", this); //In my understanding "this" referes to the constructor + I have //to do the setContextProperty before the next line to call the function myFunction
AbstractPane *root = qml->createRootObject<AbstractPane>(); //I get the root note or object here.
//In my case the navigationPane or the Page Object then in the .hpp file I do
...
public:
Q_INVOKABLE void myFunction();
...

 then in qml i can call the function with

...
app.myFunction();
...

 So I did this and it worked.


My Problem is, that my calculations and work is done in the function that is created with the creation of my Project.

So this function is called like my Project name.

i tried, but I cannot just Invoke it and call it again. When I do the error message is something like that the method cant be overloaded. When I start the app this function is called and I think it is done in the hpp file at the line:

 

...
public:
    ProjectName(bb::cascades::Application *app);
...

 I fear that all I get in response is, that I should read the Documentation:

http://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html

more carefully.

I will reread it and try more.

The problem is that I get to my limits of understanding how the whole thing works.


I continue reading now in the hope I get a clue what is going on.

 

Regards,

 

Maddin

 

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Function call problems

[ Edited ]

This function is called the constructor. In C++ it's used for initializing member variables of the class when creating a class instance. It can't be called again.

You could move the calculations to another function then call that function from constructor if needed.

 

I suggest reading a book on C++ otherwise it will be hard to work effectively with Cascades. If you have previous programming experience I suggest Bjarne Stroustrup's book "The C++ Programming Language".


Andrey Fidrya, @zmeyc on twitter
Contributor
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator
My Carrier: Me

Re: Function call problems

Hi,

 

Thank you for your reply.

 

I will consider to read Bjarne Stroustrup's book "The C++ Programming Language".

 

On the first overview it seems to be good.
 

Regards,

 

Maddin

Contributor
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator
My Carrier: Me

Re: Function call problems

Hi,

 

Ok. After some trying around I did it. With further problems, but I was able to load the calculations from another function in the Constructor.

Nevertheless, I still consider to read the book. it seems to be quite exciting. If it is from the creator of c++, which it obviously is, than its worth in reading it, plus I certainly can learn the one or another thing from it.

For now I thank you so much for helping me out.

if I can, I like your reply twice Smiley Wink

 

Regards,

 

Maddin