Quick控件--5.digital key board
- 1 效果
- 2 简介
- 3 控件代码
-
- 3.1 SenDigitalKeyBoard.qml
- 3.2 main.qml
1 效果
2 简介
digital key board控件常用,自定义备用。
3 控件代码
3.1 SenDigitalKeyBoard.qml
import QtQuick 2.12// SenComBtn control used by this controlRectangle {property int dkbFormSize: 200property int dkbFontSize: 20property int dkbBtnSize: dkbFormSize / 5property int dkbMaiginSize: dkbBtnSize / 5property color dkbTextColor: "white"property color dkbPressedTextColor: "red"property color dkbReleaseTextColor: dkbTextColorproperty color dkbBtnColor: "grey"property color dkbPressedColor: dkbBtnColorproperty color dkbReleaseColor: dkbBtnColorproperty color dkbFormColor: "lightgrey"property string leftArrow: "\u2190"property string upperArrow: "\u2191"signal btnPressed(string numb)signal quitClicked()id: digitalVKeywidth: dkbFormSizeheight: dkbFormSizecolor: dkbFormColorColumn {id: kbColanchors {horizontalCenter: parent.horizontalCenterverticalCenter: parent.verticalCentermargins: dkbMaiginSize}spacing: dkbMaiginSizeRow {spacing: dkbMaiginSizeanchors.horizontalCenter: parent.horizontalCenterSenComBtn {id: btn1width: dkbBtnSizeheight: dkbBtnSizebtnText: "7"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("7")}SenComBtn {id: btn2width: dkbBtnSizeheight: dkbBtnSizebtnText: "8"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("8")}SenComBtn {id: btn3width: dkbBtnSizeheight: dkbBtnSizebtnText: "9"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("9")}SenComBtn {id: btn4width: dkbBtnSizeheight: dkbBtnSizebtnText: leftArrowfontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("delete")}}Row {spacing: dkbMaiginSizeanchors.horizontalCenter: parent.horizontalCenterSenComBtn {id: btn5width: dkbBtnSizeheight: dkbBtnSizebtnText: "4"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("4")}SenComBtn {id: btn6width: dkbBtnSizeheight: dkbBtnSizebtnText: "5"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("5")}SenComBtn {id: btn7width: dkbBtnSizeheight: dkbBtnSizebtnText: "6"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("6")}SenComBtn {id: btn8width: dkbBtnSizeheight: dkbBtnSizebtnText: "C"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("clear")}}Row {spacing: dkbMaiginSizeanchors.horizontalCenter: parent.horizontalCenterSenComBtn {id: btn9width: dkbBtnSizeheight: dkbBtnSizebtnText: "1"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("1")}SenComBtn {id: btn10width: dkbBtnSizeheight: dkbBtnSizebtnText: "2"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("2")}SenComBtn {id: btn11width: dkbBtnSizeheight: dkbBtnSizebtnText: "3"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("3")}SenComBtn {id: btn12width: dkbBtnSizeheight: dkbBtnSizebtnText: "-"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("-")}}Row {spacing: dkbMaiginSizeanchors.horizontalCenter: parent.horizontalCenterSenComBtn {id: btn13width: dkbBtnSize * 2 + dkbMaiginSizeheight: dkbBtnSizebtnText: "0"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed("0")}SenComBtn {id: btn14width: dkbBtnSizeheight: dkbBtnSizebtnText: "."fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: btnPressed(".")}SenComBtn {id: btn15width: dkbBtnSizeheight: dkbBtnSizebtnText: "OK"fontSize: dkbFontSizetextColor: dkbTextColorpressedTextColor: dkbPressedTextColorreleaseTextColor: dkbReleaseTextColorbtnColor: dkbBtnColorpressedColor: dkbPressedColorreleaseColor: dkbReleaseColoronClicked: quitClicked()}}}
}
3.2 main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
import "./common" as SenComWindow {visible: truewidth: 640height: 480title: qsTr("Hello World")SenCom.SenDigitalKeyBoard {anchors.centerIn: parent}
}