兼容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 } }