Scale images in GridLayout (QML)



  • Hello. I'm trying to make scalable GridLayout, but scale doesn't work as i thought.

    import QtQuick 2.0
    import QtQuick.Controls 2.5
    import QtQuick.Layouts 1.3
    
    ScrollView {
        id: view
        clip: true
        contentWidth: -1
    
        GridLayout {
            anchors.fill: parent
            columns: 3
    
            Repeater {
                model: 4
                Image {
                    Layout.fillWidth: true
                    fillMode: Image.PreserveAspectFit
                    source: "/Assets/profile.png"
                }
            }
        }
    }
    

    After i decrease window's width my images scales to fit in Image.PreserveAspectFit mode. But the cell's height does not changed. So i have some kind of spacing between rows (Screenshots applied). How can i achieve proper aspect ration scale for GridLayout itself?
    0_1553989144237_BeforeScale.png
    0_1553989154610_AfterScale.png


Log in to reply
 

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