qml绘图_css

代码:

import QtQuick 2.6
import QtQuick.Window 2.2
import CapbCanvas 1.0
import CapbTextItem 1.0

Window {
visible: true
width: 640
height: 480
id:root
color: "#3A3223"
title: qsTr("CapbCanvas")
property alias operMode: canvasId.drawMode // 0:只拖动;1:测量,2:标记,3:面积
Component.onCompleted: {
canvasId.setTextItem(canvasTextId); //
}

Item{
width: parent.width
height: parent.height-50
CapbCanvas{
id: canvasId
width: parent.width
height: parent.height
clip: true
onDrawFinished: {
// operMode = 0;
}
}
CapbTextItem{
id: canvasTextId
width: parent.width
height: parent.height

}
}

Item{
width: parent.width
height: 50
y:parent.height-50
Rectangle {
id: rectangle
x: 16
y: 8
width: 79
height: 34
color: "#ffffff"

Text {
id: text1
x: 26
y: 8
width: 27
height: 22
text: qsTr("距离")
font.pixelSize: 12
}
MouseArea{
hoverEnabled: true
anchors.fill: parent
onClicked: operMode = 1;
}
}

Rectangle {
id: rectangle1
x: 101
y: 8
width: 74
height: 34
color: "#ffffff"

Text {
id: text2
x: 25
y: 8
width: 24
height: 18
text: qsTr("标记")
font.pixelSize: 12
}
MouseArea{
hoverEnabled: true
anchors.fill: parent
onClicked: operMode = 2;
}
}

Rectangle {
id: rectangle2
x: 181
y: 8
width: 77
height: 34
color: "#ffffff"

Text {
id: text3
x: 27
y: 8
width: 24
height: 18
text: qsTr("面积")
font.pixelSize: 12
}
MouseArea{
hoverEnabled: true
anchors.fill: parent
onClicked: operMode = 3;
}
}

Rectangle {
id: rectangle3
x: 269
y: 8
width: 65
height: 34
color: "#ffffff"
Text {
id: text4
x: 15
y: 8
width: 31
height: 18
text: qsTr("无")
font.pixelSize: 12
}
MouseArea{
hoverEnabled: true
anchors.fill: parent
onClicked: operMode = 0;
}
}

Rectangle {
id: rectangle4
x: 340
y: 8
width: 70
height: 34
color: "#ffffff"
Text {
id: text5
x: 8
y: 8
width: 48
height: 15
text: qsTr("清除")
font.pixelSize: 12
}
MouseArea{
hoverEnabled: true
anchors.fill: parent
onClicked: operMode = 4;
}
}
}
}