[Qt-qml] Multiple signals with same name but different parameters

Karsten Opdal karsten.s.opdal at gmail.com
Sat Feb 12 01:58:07 CET 2011


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:


class QMLClass : public QObject

{

    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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110212/e621d602/attachment-0001.html 


More information about the Qt-qml mailing list