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
Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator
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

 

 

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

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
Please use plain text.
Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator

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

Please use plain text.
Contributor
MaddinBB
Posts: 10
Registered: ‎02-25-2013
My Device: Simulator

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 :smileywink:

 

Regards,

 

Maddin

Please use plain text.