[Qt-qml] Using enums in QML signal handlers

ext-salonen.olli at nokia.com ext-salonen.olli at nokia.com
Tue Nov 2 14:06:47 CET 2010


Hi,

I have declared an enum in a class and use it as an argument in a signal. I can use the enum in QML, but I cannot read the parameter in the signal handler. Is it supposed to work somehow?

Example:

class MyObject {
  Q_OBJECT
  Q_ENUMS(MyEnum)
  Q_PROPERTY(MyEnum value READ value NOTIFY valueChanged)
public:
  enum MyEnum { Value1, Value2};
signals:
  void valueChanged(MyEnum value);
}

Qml file
----------
MyObject {
  onValueChanged: console.debug("Value is " + value)
}

This fails with the following output:
QMetaProperty::read: Unable to handle unregistered datatype 'MyEnum' for property 'QDeclarativeBoundSignalParameters::value'

I also tried to rename the signal parameter type to MyObject::MyEnum, but this did not work either. I can use the value correctly if I access it as a property, or if I assign enum values such as "property int myvalue: MyObject.Value1".

Thanks,
Olli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101102/d4e1eda4/attachment.html 


More information about the Qt-qml mailing list