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
New Developer
Posts: 14
Registered: ‎06-24-2014
My Device: BlackBerry Z10
My Carrier: Free
Accepted Solution

Interacting with C++ object injecting to QML

Hi,

I'm a new user but I learned some basic way to do what I want to develop.

I start with nothing knowledge in C++, Qt or what else but I do my best to learn.

I work on a small project but know I should use C++ objects because I want to create a dynamic UI.

In fact, I wanted to create a button in QML and then I click, a progress indicator appear. No problem, I write a little function in C++ who inject that with a Q_INVOKABLE.

But now, I want to change the values of this progress indicator with QML but how I affect an ID to this object injected. Where is appear and how I save its?

Thanks for your help!
Developer
Posts: 16,612
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Interacting with C++ object injecting to QML

welcome to the support forums.

i would suggest that you create UI objects in QML using createObject.
add an attached object with a component definition of your indicator and use that.
alternatively you could add one and toggle its visibility.
there are some other ways, but those should get you started without using c++.
----------------------------------------------------------
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
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Interacting with C++ object injecting to QML

I agree with Simon, for that simple case changing the visibility property would be sufficient.

 

However if you do want to be a bit more sophisticated have you looked at dynamically adding in QML, you might like to look at this KB article which shows you how to interact with dynamic QML componants...

 

http://supportforums.blackberry.com/t5/Native-Development-Knowledge/How-to-pass-data-to-and-from-a-Q...

 

 


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

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 14
Registered: ‎06-24-2014
My Device: BlackBerry Z10
My Carrier: Free

Re: Interacting with C++ object injecting to QML

Thanks for your answer but I want that my applications has no max progress indicator limit and it's that's why I look at C++. If I can do that only in QML, I will be very happy!!
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Interacting with C++ object injecting to QML

Not sure I understand you, what is the point of having no limit (it would never reach the end :smileyhappy:)?

If you are saying there is a difference between QML and C++ for the maximum value allowed I would be surprised at this.
... and even if there was you could always factor it.

So not sure what you mean perhaps you could explain a little bit more?

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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Interacting with C++ object injecting to QML

Yep both the QML side and C++ side use floats so not sure what you are wanting.


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

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 14
Registered: ‎06-24-2014
My Device: BlackBerry Z10
My Carrier: Free

Re: Interacting with C++ object injecting to QML

Ok so I will tell you more of y project.

 

I want to allow user to create unlimited number of timer. He will be able to create different timer with different time and different name. After, I create a function who had +1 for the first timer every second, when the first timer is finish, tha app had +1 to second timer, etc..

 

For that, I have create a little function who inject a container :

 

void ApplicationUI::createtimer(QString name, int time)
{
	mRootContainer->add(Container::create()
		.add(Header::create()
			.title(name)
			)
		.add(ProgressIndicator::create()
			.to(time)
			)
	);
}

 and then, I create a button in QML and I call this function with a Q_INVOKABLE.

 

But I can't modify value of this because I can't set an ID or anything else for this progress Indicator!

 

I prefer Qml and if I can do that only in Qml , I will be happy!! :smileytongue:

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

Re: Interacting with C++ object injecting to QML

 There is nothing there that you can't do in QML, off the top of my head so forgive the errors...

 

MyTimer.qml

Container
    property alias title: myTimer.title
    property alias to: pi.toValue

    id: myTimer

    ProgressIndicator {
        id: pi
    }
} 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Interacting with C++ object injecting to QML

Take a look at this for a better understanding of how easy it is to do a custom control that can be easily injected dynamically in to the scene graph all in QML...

 

http://developer.blackberry.com/native/documentation/cascades/ui/custom_components/


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

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 14
Registered: ‎06-24-2014
My Device: BlackBerry Z10
My Carrier: Free

Re: Interacting with C++ object injecting to QML

Thank you very much for your answer but how I integrate that in my main.qml?