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

createObject ignores null property assignment

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • 6.9
    • 6.2.9, dev
    • Quick: Controls 2
    • None
    • macOS, Windows

    Description

      It should be possible to assign null to a property when calling createObject:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      
      ApplicationWindow {
          id: window
          width: 800
          height: 600
          visible: true
      
          Component.onCompleted: {
              // Works
      //        let textArea = textAreaComponent.createObject(window.contentItem, { background: redRect })
              // No effect
              let textArea = textAreaComponent.createObject(window.contentItem, { background: null })
              title = textArea.background.toString()
          }
      
          Rectangle {
              id: redRect
              objectName: "redRect"
              color: 'red'
          }
      
          Component {
              id: textAreaComponent
              TextArea {
                  text: "TextArea"
              }
          }
      }
      

      The expected output of this example is:

      qrc:/quick/Main.qml:109: TypeError: Cannot call method 'toString' of null
      

      Tested on different platforms with different versions of qtdeclarative:

      cacb0ea963ae70f909246c1c1b639f2f78a3a003 (older) macOS - didn't work
      68ad21c13073c0e4a52d0bd7b211ac175c251c2c (newest) macOS - didn't work
      6f2722177be3ab74f04d0a88e8d0d72b8ee8920f (older) Kubuntu - worked
      68ad21c13073c0e4a52d0bd7b211ac175c251c2c (newest) Kubuntu - worked
      02c4c817fe1cfa4766c56759be99fb081382a586 (older) Windows - didn't work
      68ad21c13073c0e4a52d0bd7b211ac175c251c2c (newest) Windows - didn't work
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes