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

Behavior on ListView does not work right away if you try and use it with Component.onCompleted

    XMLWordPrintable

Details

    • 26ec7d7e407fd1b55f69d63833a3ee8af4479d85

    Description

      In the example below the behavior on Y has no effect and the behavior on the ListView does nothing. However clicking the mouse area later does work. So maybe the Behavior is not taking effect yet before the Component.onCompleted fires?

      import QtQuick 2.0
      
      Item {
          width: 300
          height: 600
          property bool listToggle: true
          
          // Make list animate right away, except the Behavior does not seem to exist yet.
          Component.onCompleted: {
              list.y = 0;
          }
      
          ListView {
              id: list
              y: 600
       
              Behavior on y {
                  NumberAnimation { duration: 3000}
              }
      
              width: 300
              height: 600
              model: 100
      
              delegate: Rectangle {
                  width: 300
                  height: 100
                  color: index % 2 ? "grey" : "lightgrey"
              }
          }
          
          // Test to see if Behavior works later, which it does
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  listToggle ? list.y = 600 : list.y = 0;
                  listToggle = !listToggle;
              }
          }
      
      }
      

      Attachments

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

        Activity

          People

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            designker Nigel Hietala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes