[Qt-qml] Using enums in QML signal handlers

jerome.pasion at nokia.com jerome.pasion at nokia.com
Fri Nov 19 23:33:48 CET 2010


Hello,

There is a similar bug that was already fixed: http://bugreports.qt.nokia.com/browse/QTBUG-11313

How do you register the enum in the Qt Declarative module?
Did you use qmlRegisterUncreatableType?
http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeengine.html#qmlRegisterUncreatableType

Thanks,
Jerome P.
________________________________________
From: qt-qml-bounces at trolltech.com [qt-qml-bounces at trolltech.com] On Behalf Of Brasser Michael (Nokia-MS-Qt/Brisbane)
Sent: Wednesday, November 03, 2010 6:26 AM
To: Olli Salonen (EXT-Futurice/Berlin)
Cc: qt-qml at trolltech.com
Subject: Re: [Qt-qml] Using enums in QML signal handlers

Hi Olli,

This sounds like a bug -- could you please create a report at bugreports.qt.nokia.com<http://bugreports.qt.nokia.com>?

Thanks,
Michael

On 02/11/2010, at 11:06 PM, ext ext-salonen.olli at nokia.com<mailto:ext-salonen.olli at nokia.com> wrote:

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
<ATT00001..txt>





More information about the Qt-qml mailing list