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

Qt: QML Iterate through listmodel in QML GridView - ScreenInfo getting created multiple time under RootWindow

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11, Windows

      Description

      Observed several ScreenInfo objects under QQmlApplicationEngine->Window

      Observed in Debug mode while debugging

      Steps to reproduce:

      Code snippet -

       ContactModel.qml

       

      import QtQuick 2.0 
       ListModel
       {  
       ListElement
      { name: "1" portrait: "pics/portrait.png" }
      ListElement
      { name: "2" portrait: "pics/portrait.png" }
      ListElement
      { name: "3" portrait: "pics/portrait.png" }
      ...
       } 
      
      

       

      main.qml

       

      import QtQuick 2.12
      import QtQuick.Window 2.12 
      Window {
      width: 640 height: 480
      visible: true title: qsTr("Hello World") 
      Rectangle {
      width: 280;
      height: 180 anchors.centerIn: parent
      color: "red" 
      Component {
      id: contactDelegate
      Item {
      width: grid.cellWidth;
      height: grid.cellHeight
      Column {
      anchors.fill: parent
      Image { 
      source: portrait; anchors.horizontalCenter: parent.horizontalCenter
      }
      Text {
       text: name; anchors.horizontalCenter: parent.horizontalCenter 
      }
      }
      }
      } 
      GridView {
      id: grid
      anchors.fill: parent
      cellWidth: 80;
      cellHeight: 80
      model: ContactModel {}
      delegate: contactDelegate
      highlight: Rectangle
      { color: "lightsteelblue"; radius: 5 }
      focus: true
      clip: true
      snapMode: GridView.SnapToRow
      flickableDirection: Flickable.VerticalFlick
      boundsBehavior: Flickable.StopAtBounds
      Component.onCompleted: { 
      console.log("Gridview Constructed...")
      }
      }
      }
      } 
      

       

      Steps:

      ->keep debug point at console.log("Gridview Constructed...")

      ->Start debugging

      -> press F5 to continue

      -> observe the debug winow, travel grid items multiple times

      > we can observe ScreenInfo objects created multiple times under QQmlApplicationEngine>Window

      -> ScreenInfo objected never destroyed

      -> please find the attached screenshot for more info

      -> please find the attached complete example code project

       

       

       

        Attachments

        1. ScreenInfo-testapp-1.jpg
          ScreenInfo-testapp-1.jpg
          316 kB
        2. grid.zip
          8 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            rajaanki RajaSekhara Reddy A
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes