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

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

XMLWordPrintable

    • cca6e8e3bd80824ff5aa3e17995a5b46ad48be28

      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
      

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes