Image.PreserveAspectCrop how to set anchors?



  • Hi,

    is there a way to add an anchor or alignment to a picture if used with
    Image.PreserveAspectCrop?

    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 :
    @
    Rectangle{
    id: container
    clip: true
    ...

     Image{
         anchors.top: container.top
         anchors.horizontalCenter: container.horizontalCenter
         ...
     }
    

    }
    @



  • Yes, thanks for your help!


Log in to reply
 

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