区别:
- 在qt5中要想设置单独的一个角的圆角,只能通过自定义的控件或者说clip属性来实现.
- 而QT6中引入的对应的属性可以来直接设置。
QT5:
- 在qt5中我们可以利用clip属性,然后配合Item作为此控件的父类,适当移动x,y起始位置,等一系列自定义方法去实现这个功能。
cpp
复制代码
import QtQuick
import QtQuick.Controls
Window
{
width: 400
height: 300
visible: true
color: "#F0F0F0"
Item
{
width: 100
height: 100
anchors.centerIn: parent
clip: true
Rectangle
{
width: 100
height: 100
radius: 20
y:20
x:20
}
}
}
QT6
cpp
复制代码
import QtQuick
import QtQuick.Controls
Window
{
width: 400
height: 300
visible: true
color: "#F0F0F0"
Rectangle
{
width: 100
height: 100
topLeftRadius: 20
topRightRadius: 20
}
}