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

Property: Assignment of inherited object regression

    XMLWordPrintable

Details

    • dcfe085ba5ff6ea82f67c4fb39e08aeb7abd1ec9 (qt/qtquickcontrols2/6.1)

    Description

      It should be possible to assign an object of type C to a property of type A given this inheritance: C < B < A.

      Example:

      MyDialog inherits QtQuick.Controls.Dialog which inherits QtQuick.Controls.Popup. So binding a MyDialog instance to a "Popup" property should work (and does work in 5.12.x).

      However the following minimal example results in the property binding not working and an error message "qrc:/main.qml:15:5: Unable to assign MyDialog_QMLTYPE_11 to Popup_QMLTYPE_1".

      main.qml

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
      
        MyDialog {
          id: dlg
        }
      
        PopupOpener {
          popup: dlg
        }
      }
      

      MyDialog.qml

      import QtQuick.Controls 2.12
      
      Dialog {
      
        contentItem: Label {
          text: "Hello"
        }
      }
      

      PopupOpener.qml

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      Button {
      
        property Popup popup;    // error in 5.15: qrc:/main.qml:15:5: Unable to assign MyDialog_QMLTYPE_11 to Popup_QMLTYPE_1
      //  property Dialog popup; // ok
      
        onClicked: popup.open()
        text: "Open Popup"
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              njeisecke Nils Jeisecke
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes