gpt4 book ai didi

qt - 有没有办法为不同的角指定不同的半径

转载 作者:行者123 更新时间:2023-12-04 00:06:43 26 4
gpt4 key购买 nike

任何人都可以帮助我如何只圆角矩形的一个角,如附图所示,其中红色矩形是我的子矩形。

实际上,我有一个矩形,其中所有四个角都是圆角(半径 10)。现在,我想在其中绘制一个新的矩形,并期望只有接触父圆角的那个特定角应该是圆角的。

enter image description here

Rectangle
{
id: parent
radius: 10
width: 168
height: 168
visible: true
color: "black"

Rectangle
{
id: child
width: 100
height: 40
color: "red"
}
}

我试图通过在 child 中添加剪辑属性来做到这一点,但什么也没发生。

最佳答案

这是一个简单的例子。
它在左上角是圆形的,但很容易调整到任何其他角。此解决方案仅支持一个角,但对您来说可能就足够了吗?
更多的角落稍微复杂一点,所以再次询问您是否也需要这些。

Rectangle {
anchors.centerIn: parent
id: root
radius: 20
width: 300
height: 300

Rectangle {
id: clipper
width: 100
height: 100
color: 'transparent'
clip: true

Rectangle {
id: clipped
width: parent.width + radius
height: parent.height + radius
radius: root.radius
color: 'red'
}
}
}

关于qt - 有没有办法为不同的角指定不同的半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39958076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com