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

qmllint type assertion (as-casts) failing with Dialog in Loader

    XMLWordPrintable

Details

    Description

      When using an as-cast to deal with qmllint warnings, the follow example works with the linter but fails at runtime:

       

      import QtQuick.Controls as CON2
      Item {
              
              CON2.Button {
                      text: "Launch dialog"
                      
                      onClicked: {
                              d_dialogLoader.active = true
                              (d_dialogLoader.item as CON2.Dialog).open()
                      }
          }
              Loader {
                      id: d_dialogLoader
                      active: false
                      sourceComponent: CON2.Dialog {
                              standardButtons: CON2.Dialog.Ok | CON2.Dialog.Cancel
                              contentItem: Rectangle {
                                      implicitWidth: 200
                                      implicitHeight: 200
                                      color: "green"
                              }
                      }
              }
      }
      

       

      The following runtime error is generated when the button is clicked:  "TypeError: true is not a function"

      The following does work (removing the as-cast)

      d_dialogLoader.item.open()

      Attachments

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

        Activity

          People

            olivier.decanniere Olivier De Cannière
            matthewf.za Matthew Fincham
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes