Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73750

Q_ENUM value undefined in QML Connections object

    XMLWordPrintable

Details

    • 01f9c623ed2dc1645ac022d69062f720e3b50132 (qt/qtdeclarative/5.12)

    Description

      Scenario:

      Qt Quick 2 based app, with a C++ QObject (named Proxy) which acts as a signal/slot proxy between QML and C++.

      The object is registered into QML with qmlRegisterUncreatableType<Proxy>(...) (or qmlRegisterType<Proxy>(...), it doesn't make a difference).

      The object defines an enum Proxy::MyEnum, registered with Q_ENUM, and also with qRegisterMetaType<Proxy::MyEnum>(), and also respecting the convention of having the enum items starting with a capital letter, 

      At application startup, in C++, a context property is set to hold the instance of the Proxy object; also, the QML object defining the signals is found, and is connected to the respective slots of Proxy. In QML there is a Connections object which connects to the signals emitted by Proxy.

       

      Issue:

      At runtime, on QML side, Proxy.EnumValue is defined in handlers such as Component.onCompleted, Button.onClicked, but it is undefined in Connections.onFooChanged.

       

      Repository with minimal test case: https://github.com/fferri/qml-enums.git

       

      Testcase output on my machine: 

      qml: Component.onCompleted: Proxy.EnumValue = 20
      qml: testButton.onClicked: Proxy.EnumValue = 20
      Proxy::initFoos
      qml: Connections.onFooChanged: index = 0, e = 20, v = 100
      qml: Connections.onFooChanged: Proxy.EnumValue = undefined
      qml: Connections.onFooChanged: index = 1, e = 21, v = 550
      qml: Connections.onFooChanged: Proxy.EnumValue = undefined

      Attachments

        Activity

          People

            ulherman Ulf Hermann
            m3hb m3hb
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: