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. Image.PreserveAspectCrop how to set anchors?
Forum Updated to NodeBB v4.3 + New Features

Image.PreserveAspectCrop how to set anchors?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.6k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      apap_
      wrote on last edited by
      #2

      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
           ...
       }
      

      }
      @

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bkamps
        wrote on last edited by
        #3

        Yes, thanks for your help!

        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