12-27-2012 04:51 AM - edited 12-27-2012 04:51 AM
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 ?
Like,
Button {
text: "Add container"
onClicked: {
injection.playSound();
}
}
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.
Regards,
Dhanesh
Solved! Go to Solution.
12-27-2012 08:40 AM
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/
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/
12-27-2012 10:14 AM - edited 12-27-2012 10:15 AM
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:
injection.playSound(idOfYourButton);
12-28-2012 12:11 AM