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

"TypeError: Cannot read property 'text' of null" with Tumbler.currentItem

    XMLWordPrintable

Details

    • cca6e8e3bd80824ff5aa3e17995a5b46ad48be28

    Description

      The following code worked in Qt 5.7:

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.3
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Component.onCompleted: {
              tumbler.currentIndex = 2
          }
      
          Row {
              Tumbler {
                  id: tumbler
                  model: 5
                  // ...
              }
      
              Label {
                  text: tumbler.currentItem.text
              }
          }
      }
      

      In Qt 5.9, setting the index doesn't work, and the binding logs the following error message:

      qrc:/main.qml:19: TypeError: Cannot read property 'text' of null
      

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              VersalEszett Julius Bullinger
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes