You need to have a valueChanged signal which takes a QVariant as its parameter, not the individual types. I believe that since the Q_PROPERTY is defined as a QVariant type, then that is what QML will respond to.


On 02/11/2011 06:58 PM, Karsten Opdal wrote:
Hi,

I'm have been developing on a major project where we are using QtDeclarative C++ to interface with the QML. Lately I found a problem with Q_PROPERTY and NOTIFY member in one of our C++ classes that are in to the context of a QML, the problem is that we are using a NOTIFY signal that are defined multiple times with different parameters, example:


classQMLClass :publicQObject
{
     Q_OBJECT
     Q_PROPERTY(QString  name  READ  getName()  WRITE  setName  NOTIFY  
nameChanged);
     Q_PROPERTY(QVariant  value  READ  getValue  WRITE  setValue  NOTIFY  
valueChanged);

...

signals:
     void  nameChanged();

     void  valueChanged();

     void  valueChanged(qint32  a_Value);

     void  valueChanged(QString  a_Value);

     void  valueChanged(bool  a_Value);


}


Signals are emitted like this:





             {
                 emit  valueChanged(useValue);


                 emit  valueChanged();


             }

QML looks like this:

     Connections  {
         id:  test


         target:  myProperty.value


         onValueChanged:  {


             console.log("value  changed  to  "  +  myProperty.value)


         }

     }
Problem is that the slot for the signal "onValueChanged" is never executed. If 
I change to NOTIFY to other signal that only exits with one prototype, it works, ie 
Q_PROPERTY( QVariant value READ getValue WRITE setValue NOTIFY otherValueChanged) and of 
course  changed the appropriate signal/slots in the QML.



Is this a BUG in QML ?



Best regards,



Karsten Sperling Opdal





_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to