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

qmltc: Enforce required properties

    XMLWordPrintable

Details

    • 18acf564f (dev), fe6f283a5 (dev), d48b5545a (dev), b6b934f83 (dev), 618b9af67 (dev)

    Description

      In the attached project, MySquare.qml is compiled with qmltc:

      // MySquare.qml
      import QtQuick
      
      Rectangle {
          required color
          width: 100
          height: 100
      }
      

       
      If we create an instance of MySquare without specifying a value for color...

      • ...the instance created in QML produces the error, "Component is missing required property color from Rectangle [required]"
      • ...the instance created in C++ silently uses the default value, "#ffffff"

       

      Note: There is no way to "atomically" set the initial properties from C++. They must currently be set after creation has completed.

       

      Suggestion

      qmltc-compiled classes should provide a way to specify initial property values (QTBUG-120700) and enforce them for required properties.

      Attachments

        Issue Links

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

          Activity

            People

              diseraluca Luca Di Sera
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: