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
Regular Contributor
Posts: 75
Registered: ‎11-30-2012
My Device: curve
Accepted Solution

Connecting to signals (with parameter)in QML.

Hello,

 

I want to connect a signal (with parameter) in QML. I emit the signal from my cpp and I am able to get that in QML, when I use signals that has no parameter.

 

I want to connect to signals that takes parameter.

 

app.mySignal.connect(button.doSomething);

 

I do emit mySignal(), works fine.

 

Want to do something like emit mySignal(int) and acess that in QML

 

-thanks

 

 

Developer
Posts: 16,575
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Connecting to signals (with parameter)in QML.

the parameters are there in qml, in your case you could add a parameter to the target function doSomething and access that as an int.
----------------------------------------------------------
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
Regular Contributor
Posts: 75
Registered: ‎11-30-2012
My Device: curve

Re: Connecting to signals (with parameter)in QML.

Can u please give a small example, for accesing the param?

Developer
Posts: 16,575
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Connecting to signals (with parameter)in QML.

your signal is:

mysignal(QString)

then you connect it to a function like that (in qml)

myClass.mysignal.connect(onmysignal)

 

and have:

function onmysignal(mystring){

console.log("my string is: "+mystring)

}

 

if you have multiple parameters you have to be careful with the order, and best use descriptive names, as there are no types in the function definition.

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