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. Crop an image in one way
Forum Update on Monday, May 27th 2025

Crop an image in one way

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 536 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.
  • D Offline
    D Offline
    DavidM29
    wrote on last edited by DavidM29
    #1

    Hello I would like to show an image on top of another and crop one of the in one way in order to make some kind of gauge of the shape of an Image.
    I tried something but it does not crop in one way only there is a moment where it crop the top and the bottom of the image.
    How could I achieve my cropping properly ?

    Here is what I have tried :

        Image {  //The background image
            anchors.top: slider.bottom  //I use a slider to change the height of the filling
            id: background
            source: "back.svg"
            z:10
            Image { //My filling imag
                 width : parent.width
                anchors.bottom: parent.bottom //I anchor this to the bottom il order to have the filling coming from the bottom to the top 
                id: filling
                source: "fill.svg"
                fillMode : Image.PreserveAspectCrop //Whant to keep the image shape so it fills properly the backgroud image
                height: background.height*slider.value/100 //Change the height of the filling image 
                z:0
            }
        }
    
    ODБOïO 1 Reply Last reply
    0
    • D DavidM29

      Hello I would like to show an image on top of another and crop one of the in one way in order to make some kind of gauge of the shape of an Image.
      I tried something but it does not crop in one way only there is a moment where it crop the top and the bottom of the image.
      How could I achieve my cropping properly ?

      Here is what I have tried :

          Image {  //The background image
              anchors.top: slider.bottom  //I use a slider to change the height of the filling
              id: background
              source: "back.svg"
              z:10
              Image { //My filling imag
                   width : parent.width
                  anchors.bottom: parent.bottom //I anchor this to the bottom il order to have the filling coming from the bottom to the top 
                  id: filling
                  source: "fill.svg"
                  fillMode : Image.PreserveAspectCrop //Whant to keep the image shape so it fills properly the backgroud image
                  height: background.height*slider.value/100 //Change the height of the filling image 
                  z:0
              }
          }
      
      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi @DavidM29 ,
      Show the Slider code please.

      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