Qml Image viewer via Gridview and C++ QStandardModelItem very slowly on Android



  • Hi,
    I'm just implementing an qml image viewer via Gridview and C++ QStandandardModelItem on Android but the loading of the images is unfortunatley slowly. I'm considering the hints descript in https://wiki.qt.io/Qt_Quick_Image_Viewer_Tutorial.

    1. sourceSize.width: width
    2. cacheBuffer: 0
      "This property determines whether delegates are retained outside the visible area of the view."

    As I understand first only the elements visible in the viewport should be loaded/displayed. But in my case all elements (also outside the viewport) from bottom to top are loaded?

    // parent.qml
    Item {
          width: parent.width
          height: parent.height
                    
          Flickable {
                anchors.fill: parent
                contentWidth: parent.width
                contentHeight: iPage.height
                focus: true
                clip: true
                boundsBehavior: Flickable.StopAtBounds
    
                Loader {
                     id: iPage
                     width: parent.width
                     height: childrenRect.height
                     source: "child.qml"
                     visible: status == Loader.Ready
                 }
    
                 ScrollBar.vertical: ScrollBar { }
           }
    }
    
    // child.qml
    Item {
        height: childrenRect.height
       
        Component.onCompleted: {
            Imag.setModel();
        }
    
        GridView {
            id: iGridView
            width: parent.width
            height: childrenRect.height
            cellWidth: width / 2
            cellHeight: cellWidth * 9 / 16
            verticalLayoutDirection: GridView.TopToBottom
            model: Imag
            delegate: iImageDelegate
            focus: true
            cacheBuffer: 0
        }
    
        Component {
           id: iImageDelegate
    
           Item {
               id: iRect
               width: iGridView.cellWidth
               height: iGridView.cellHeight
               
               Image {
                   id: iImage
                   width: parent.width - cSize / 6
                   height: parent.height - cSize / 6
                   anchors.centerIn: parent
                   asynchronous: true
                   source: src
                   sourceSize.width: 50
                   sourceSize.height: 30
                   fillMode: Image.PreserveAspectCrop
                   smooth: false
                }
            }
        }
    
        Component.onDestruction: {
            Imag.clearModel();
        }
    }
    
    

    Does maybe someone hast an idea what I'm doing wrong/not optimal or how can I improve the loading velocity? Thxs in advance...



  • The problem was the 'height' in the Loader. There must be a concret value.

    // parent.qml
    Loader {
           id: iPage
           width: parent.width
           height: childrenRect.height
           source: "child.qml"
           visible: status == Loader.Ready
    }
    

    e.g.

    height: parent.height
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.