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

Implicit conversion to Component doesn't work in inline components

    XMLWordPrintable

Details

    • ec25258 (dev), f751745 (6.6)

    Description

      I've discovered yet another bug with inline components.

      In a regular component, you can define a property such like this:

      property Component comp: null
      

      And later you can override the property like this:

      comp: Item { }
      

      But not with inline components. The implicit conversion doesn't kick in, and the runtime crashes.

      It does work as expected like this:

      comp: Component { Item { } }
      

      OK, here is a complete example that reproduces the problem:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
        width: 640
        height: 480
        visible: true
      
        component C1 : Item {
          property Component comp: null
        }
      
        component C2 : C1 {
          comp: Rectangle { width: 50; height: 50; color: "red" } // still null
        }
      
        component C3 : C1 {
          comp: Component { Rectangle { width: 50; height: 50; color: "red" } } // ok here
        }
      
        C2 { id: c2 }
        C3 { id: c3 }
      
        Component.onCompleted: console.log(c2.comp, c3.comp)
      }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-98859
          # Subject Branch Project Status CR V

          Activity

            People

              ulherman Ulf Hermann
              dgo dgo
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes