Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Scale images in GridLayout (QML)

Scale images in GridLayout (QML)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HandzoHasashi
    wrote on last edited by HandzoHasashi
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved