title: ColumnLayout with images occupying only the minimum space in QML
body: <p>I have a <code>ListView</code> with <code>ColumnLayout</code> delegates containing images that could be of any size. I want each delegate to occupy the least possible width and height they can, only defining a certain maximum width, but I can't get images to size right instead of being centered in a box (shown by the gray rectangles here):</p>
  
  <p><a href="https://i.stack.imgur.com/f9IFx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f9IFx.png" alt="Current result"></a></p>
  
  <p>My code is this:</p>
  
  <pre><code>import QtQuick 2.12
  import QtQuick.Controls 2.12
  import QtQuick.Layouts 1.12
  
  ApplicationWindow {
      id: window
      width: 640
      height: 800
      visible: true
      color: "black"
  
      ListView {
          id: listView
          anchors.fill: parent
          model: 3
  
          delegate: ColumnLayout {
              width: listView.width
  
              Label {
                  text:
                      "Lorem ipsum dolor sit amet, consectetuer adipiscing " +
                      "Aenean commodo ligula eget dolor. Aenean massa."
                  color: "white"
                  wrapMode: Text.Wrap
                  font.pixelSize: 22
  
                  Layout.maximumWidth: listView.width / 2
              }
  
              Image {
                  asynchronous: true
                  source: "https://picsum.photos/1024/256"
                  fillMode: Image.PreserveAspectFit
  
                  Layout.maximumWidth: listView.width / 2
  
                  Rectangle { anchors.fill: parent; color: "#222"; z: -1 }
              }
          }
      }
  }
  </code></pre>
  
  <p>I can get the right behavior when using <code>Column</code> instead of <code>ColumnLayout</code> and replacing the <code>Layout.maximumWidth</code> lines by <code>width: Math.min(implicitWidth, listView.width / 2)</code>, as shown below, but I need to use layouts in my project:</p>
  
  <p><a href="https://i.stack.imgur.com/lgQH2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lgQH2.png" alt="Wanted result"></a></p>