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

qml: allow enums as function parameters

    XMLWordPrintable

Details

    Description

      See attached example:

      What works: if I have an enum declared by Q_ENUMS, then in qml I can use its values (by ClassName.ENUM_ID):

      In TestClass declaration
      Q_ENUMS(test_enum)
      enum test_enum { ENUM1, ENUM2 };
      
      In qml
      console.log("TestClass.ENUM1 == " + TestClass.ENUM1);
      

      returns:

      TestClass.ENUM1 == 0
      

      Similarly one can use enums for properties.


      What does not work: if I have a public slot:

      In TestClass declaration
      QString testFunction(test_enum)
      

      then

      In qml
      console.log(instance.testFunction(TestClass.ENUM1));
      

      gives an error:

      test.qml:12: Error: Unknown method parameter type: test_enum


      So the request is: please enable the last structure: please enable calling from qml slots which arguments are declared enums of classes registered by qmlRegisterType.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            wiecko Marek Wieckowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes