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

New Developer
Posts: 28
Registered: ‎12-19-2012
My Device: BB 10
My Carrier: BB
Accepted Solution

How Pass 'SIGNAL' object as parameter from QML

[ Edited ]

Hello All,

I am in a basic need of having the Object which caused the SIGNAL to occur, 

Ex. through a signal 'onClicked' (in QML) from button if I am calling a SLOT method or Q_INVOKABLE, then can I have 

the calling Object ?




Button {

                text: "Add container"

                onClicked: {





The code is taken from the tutorial. As you can see the 'injection' is through 'setContextProperty' and having 

'playSound' Method I want to do some thing like this

 injection.playSound('Button Object which invoked this signel (onClicked)');  


and the curresponding Method in the class will look like.


Q_INVOKABLE void playSound(bb::cascades::Button* buttonObject);


Any one ?? Please help me in this regard.

RIM, Please have a look at these simple things and update the documents.





Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: How Pass 'SIGNAL' object as parameter from QML

Not exactly sure what your question is...


But if you are having issues with connecting QML with C++, meaning you want to use the context property to run a Q_INVOKABLE functions using a QML signals which will perform a C++ function take a look at this tutorial: http://bbcascadescode.tumblr.com/post/29294239402/running-c-function-from-qml-trivial-example


If you have a question specific to playing sounds, it is very easy to play them using the MediaPlayer{}, which I explain briefly in this tutorial: http://bbcascadescode.tumblr.com/post/38199821341/lions-tabs-and-bears-oh-my

Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Posts: 285
Registered: ‎08-06-2010
My Device: Z10

Re: How Pass 'SIGNAL' object as parameter from QML

[ Edited ]

In c++ make your method in your header


Q_INVOKABLE void playSound(QObject* buttonObject);

 In your cpp file


MyClass::void playSound(QObject* buttonObject) {

// Cast QObject to Button
Button* myButton = qobject_cast<Button *>(buttonObject);

// Logic Here



In your QML file:





Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
New Developer
Posts: 28
Registered: ‎12-19-2012
My Device: BB 10
My Carrier: BB

Re: How Pass 'SIGNAL' object as parameter from QML

Wow thanks a lot !! It worked !!