三角形控件(Triangle),等腰直角三角形。底是高的两倍。

| Triangle |
备注 |
| 导入方法 |
文件导入 |
| 兼容性 |
QtQuick 1.x和QtQuick 2.x
|
| 继承 |
Item |
示例
Triangle {
anchors.centerIn: parent
}
属性
-
width:设置三角形的等宽。
-
color:设置三角形的颜色。
源码
//#if Qt4
//import QtQuick 1.0
//#else
import QtQuick 2.0
//#endif
Item {
id: root
property alias color: triangle.color
implicitWidth: 100
implicitHeight: implicitWidth
width: implicitWidth
height: width
clip: true
rotation: -45
Rectangle {
id: triangle
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: parent.height/2
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -parent.width/2
width: Math.sqrt(root.width * root.width * 2)
height: width
color: "#4cbeff"
rotation: 45
}
}
关于更多
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论