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

Issues with required properties in view delegates

    XMLWordPrintable

    Details

    • Platform/s:
      Windows

      Description

      Using a required property inside a View or Repeater prevents destructors from being called on custom C++ types created by the delegate. This occurs if the required property is declared in the view's delegate directly or wrapped in a type used by the delegate.

      Furthermore, when a custom QML type (MyQmlType attached) was used to introduce a required property, the 'model' keyword became unavailable in the delegate. Based on the model-view documentation for required properties, I had expected the 'model' keyword to be removed only for top level required properties. Allowing subcomponents to trigger this behavior limits reusability.

      Example code is attached. QDebug print statements were used to track MyType object creation and destruction.

      When 'regular' properties are used, MyType is created and destroyed as expected:
      MyType Created
      MyType Created
      MyType Created
      MyType Deleted
      MyType Deleted
      MyType Deleted

      When a 'required' property is introduced, at any level in the delegate, the MyType destructor is no longer called:
      MyType Created
      MyType Created
      MyType Created

        Attachments

        1. main.cpp
          0.7 kB
        2. main.qml
          1.0 kB
        3. MyQmlType.qml
          0.1 kB
        4. MyType.cpp
          0.2 kB
        5. MyType.h
          0.2 kB
        6. qml.qrc
          0.1 kB
        7. RequiredPropertyBug.pro
          0.7 kB
        8. test.zip
          3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            tvoils Thomas Voils
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes