Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    QML and Qt Quick
    3
    5
    3630
    Loading More Posts
    • 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
      Quizilla last edited by

      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 Reply Quote 0
      • H
        hmuelner last edited by

        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 Reply Quote 0
        • Q
          Quizilla last edited by

          Thanks!

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

          1 Reply Last reply Reply Quote 0
          • p3c0
            p3c0 Moderators last edited by

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

            157

            1 Reply Last reply Reply Quote 0
            • Q
              Quizilla last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post