123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import QtQuick 2.12
- import QtQuick.Controls 2.12
- Item {
- id:root
- anchors.fill: parent
- anchors.margins: 1
- property int fontsize:14
- property string fontcolor:"black"
- //property string text:"0.000"
- //property int value:0
- //property int value_tmp:0
- property string text_state1:"合格"
- property string text_state2:"不合格"
- property string text_state3:"无此项"
- signal usateChanged
- state: "0"
- states:[
- State {
- name: "0"
- PropertyChanges {target:rb1; checked:true}
- PropertyChanges {target:rb2; checked:false}
- PropertyChanges {target:rb3; checked:false}
- },
- State {
- name: "1"
- PropertyChanges {target:rb1; checked:false}
- PropertyChanges {target:rb2; checked:true}
- PropertyChanges {target:rb3; checked:false}
- },
- State {
- name: "2"
- PropertyChanges {target:rb1; checked:false}
- PropertyChanges {target:rb2; checked:false}
- PropertyChanges {target:rb3; checked:true}
- }
- ]
- ButtonGroup{
- id:group
- buttons: row.children
- /*
- onClicked:{
- //console.log("tristate clicked:", button.text)
- var old_state = state
- if(text_state1 === button.text){
- state = "0"
- }else if(text_state2 === button.text){
- state = "1"
- }else if(text_state3 === button.text){
- state = "2"
- }
- if(old_state !== state){
- //value = value_tmp
- root.usateChanged()
- }
- }
- */
- }
- Row{
- id: row
- UserRadioButton{
- id:rb1
- checked: true
- text: text_state1
- font.pixelSize: fontsize
- onCheckedChanged: {
- if("0" !== root.state){
- //console.log("rb1 onCheckedChanged, rootstate:" , root.state)
- root.state = "0"
- root.usateChanged()
- }
- }
- }
- UserRadioButton{
- id:rb2
- checked: false
- text: text_state2
- font.pixelSize: fontsize
- onCheckedChanged: {
- if("1" !== root.state){
- //console.log("rb2 onCheckedChanged, rootstate:" , root.state)
- root.state = "1"
- root.usateChanged()
- }
- }
- }
- UserRadioButton{
- id:rb3
- checked: false
- text: text_state3
- font.pixelSize: fontsize
- onCheckedChanged: {
- if("2" !== root.state){
- //console.log("rb2 onCheckedChanged, rootstate:" , root.state)
- root.state = "2"
- root.usateChanged()
- }
- }
- }
- }
- }
|