Important: Please read the Qt Code of Conduct -

Image.PreserveAspectCrop how to set anchors?

  • Hi,

    is there a way to add an anchor or alignment to a picture if used with

    By default the picture is centered inside the Image element. I'd like to
    have the pictures top edge anchored to the Image elements top edge and
    centered horizontally.

    Is this achievable using QML?

  • I'm not sure to well understand your question but I think you can put the Image Element in a Rectangle Element and deal with his "clip" property :
    id: container
    clip: true

         anchors.horizontalCenter: container.horizontalCenter


  • Yes, thanks for your help!

Log in to reply