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

QML tools: Improve ability to resolve types that are not fully-qualified

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • 6.12
    • None
    • None

      There are no problems with the Q_PROPERTY declaration or the property bindings, so I presume that it should be possible to resolve the signal parameter too?

       

      Code
      cppobj.h

      class CppObj : public QObject
      {
          Q_OBJECT
          QML_ELEMENT
          Q_PROPERTY(MyEnum value READ value WRITE setValue NOTIFY valueChanged FINAL)
      
      public:
          explicit CppObj(QObject *parent = nullptr) : QObject(parent) {}
      
          enum MyEnum {
              Alpha,
              Bravo,
              Charlie
          };
          Q_ENUM(MyEnum)
      
          MyEnum value() const { return m_value; }
          void setValue(MyEnum value)
          {
              if (m_value == value)
                  return;
              m_value = value;
              emit valueChanged(m_value);
          }
      
      signals:
          void valueChanged(MyEnum value); // qmllint and qmlsc need this to be fully-qualified, "CppObj::MyEnum"
      
      private:
          MyEnum m_value = Alpha;
      };
      

       

      Main.qml

      import QtQuick
      import TypeQualificationStudy
      
      Window {
          width: 600
          height: 400
          visible: true
      
          CppObj {
              id: cppObj
              value: CppObj.Bravo // OK
              onValueChanged: console.log(value) // Warning: Type MyEnum of parameter value in signal called valueChanged was not found, but is required to compile onValueChanged.
          }
      
          Component.onCompleted: console.log(cppObj.value) // OK
      }
      

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

            qtqmlteam Qt Qml Team User
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes