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
Developer
Posts: 136
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900
My Carrier: Bell
Accepted Solution

Signal simple question...

I'm trying to hook up a simple signal with no params... But I just can't get my hands on the proper syntax !

The example I'm looking at has the following syntax :

class MyDataModel: public bb::cascades::GroupDataModel
{
Q_OBJECT

Q_PROPERTY(QString myField READ myField WRITE setMyField 
    NOTIFY myFieldChanged)
...

  void myFieldChanged(QString value);

  QString myField ();

signals:
  void myFieldChanged(QString value);

 
In QML, I hook up the signal using the following :

  onMyFieldChanged: 
  {
    // When the signal is fired.
    console.log("onMyFieldChanged()");     
  } 


I would like to add two new signal, but both signal do not require read and write properties...

signals:
  void dataFetchStart();
  void dataFetchEnd();


What would be the syntax required in my*.h file... The following syntax does not cause the compiler to throw up... but I cannot hook my signal in QML..

Q_PROPERTY(NOTIFY dataFetchStart)
Q_PROPERTY(NOTIFY dataFetchEnd)

 

Developer
Posts: 84
Registered: ‎12-01-2012
My Device: 9790
My Carrier: Orange

Re: Signal simple question...

Just use:

Q_SIGNAL dataFetchStart() etc. instead of Q_PROPERTY. The property is for values that you would like to propagate to QML.
Lublin BlackBerry Developer Group


---
If I helped you please mark my response as solution or "Like" it.
Developer
Posts: 84
Registered: ‎12-01-2012
My Device: 9790
My Carrier: Orange

Re: Signal simple question...

And note that the signal myFieldChanged does not have to contain any parameters. When the signal is invoked the QML object updates the value with "getter" defined by READ parameter in Q_PROPERTY
Lublin BlackBerry Developer Group


---
If I helped you please mark my response as solution or "Like" it.
Developer
Posts: 136
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900
My Carrier: Bell

Re: Signal simple question...

Ok, I'm missing a piece... I just tried the signal code... add the following to my *.h file and the compiler was able to compile...

 

signals:
  void userHandleChanged(QString userHandle);
  Q_SIGNAL void loadStarted();
  Q_SIGNAL void loadCompleted();

 
Now from my QML file, I can see the onUserHandleChanged() signal but the two other are not displayed in the dropdown list plus I get "unknown symbol" error !! See attached image...

Developer
Posts: 136
Registered: ‎01-25-2010
My Device: Z30, Z10, Q10, Dev Alpha B & Bold 9900
My Carrier: Bell

Re: Signal simple question...

My mistake... code typo... Thanks !