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. Rounded Image Corners
Qt 6.11 is out! See what's new in the release blog

Rounded Image Corners

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.3k 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.
  • P Offline
    P Offline
    PsAePr
    wrote on last edited by
    #1

    Hi there,
    i'm trying to create a rectangle with an image in it. The rectangle should have rounded corners.
    My code looks like this:
    @import QtQuick 2.0

    Image {
    id: background
    source: "../background.jpg"
    width: 360
    height: 360
    focus: true

    Rectangle {
        id: rectangle
        x: 30
        y: 30
        width: 300
        height: 300
        color: "#ffffff"
        radius: 20
        border.width: 5
        border.color: "#000000"
    
        Image {
            id: image
            width: 300
            height: 300
            source: "../example.jpg"
        }
    }
    

    }@

    My problem is, that the image is still an rectangle without rounded corners.
    Does anyone know how to fix that?

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

      Enable clipping on the rectangle.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PsAePr
        wrote on last edited by
        #3

        Hi Andre,
        thanks for your reply.
        However enabling clipping sadly did not solve the problem.

        This is the updated code:
        @import QtQuick 2.0

        Image {
        id: background
        source: "../background.jpg"
        width: 360
        height: 360
        focus: true

        Rectangle {
            id: rectangle
            x: 30
            y: 30
            width: 300
            height: 300
            color: "#ffffff"
            radius: 20
            border.width: 5
            border.color: "#000000"
            clip: true
        
            Image {
                id: image
                width: 300
                height: 300
                source: "../example.jpg"
              
            }
        }
        

        }
        @

        Do you have an idea how to fix this issue?

        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