兼容Qt4/Qt5版本Qml控件Triangle
- 2019 年 10 月 30 日
- 筆記
三角形控件(Triangle),等腰直角三角形。底是高的两倍。
文件导入
示例
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 } }