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. How to crop an image inside an item (rectangle)?
QtWS25 Last Chance

How to crop an image inside an item (rectangle)?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 4.1k 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.
  • Q Offline
    Q Offline
    Quizilla
    wrote on last edited by
    #1

    Hi,

    I would like to load and display a picture (.png) inside a circle (rectangle) that I have defined. I have done some tries with Image.PreserveAspectCrop but they were not conclusive. I want my image to perfectly fit the border of the circle. Is that possible with Qt Quick?

    Thanks a lot!

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hmuelner
      wrote on last edited by
      #2

      You could use a Canvas and the clip API (see "the Canvas example":http://qt-project.org/doc/qt-5/qtquick-canvas-example.html

      Helmut Mülner

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Quizilla
        wrote on last edited by
        #3

        Thanks!

        I will investigate this path and hopefully this would help me!

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Or you could use "OpacityMask":http://qt-project.org/doc/qt-5/qml-qtgraphicaleffects-opacitymask.html.

          157

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Quizilla
            wrote on last edited by
            #5

            Woooow! Perfect! That's exactly what I need! Thank you so much

            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