Swtich button - disable switch with spacebar
-
Hi,
I am using Switch "button" and when I press the spacebar key the switch is toggling. How can I disable it? I want to toggle it only when I click by mouse on it. Thank you!
Switch { id: control text: qsTr("mode") font.pixelSize: 16*Constants.PYSIDE6_TO_2_RESIZE font.bold: false font.italic: true checked:true anchors.left: btnStart.horizontalCenter anchors.top: btnStart.top //anchors.topMargin: 60 anchors.leftMargin: 130 indicator: Rectangle { implicitWidth: 45 implicitHeight: 16 anchors.top: control.top anchors.topMargin: 5 // x: control.width - width - control.rightPadding //y: control.top //- height / 2 radius: 10 color: control.checked ? Constants.XGREEN : Constants.XWHITE border.color: "black" Rectangle { x: control.checked ? parent.width - width : 0 width: 22 height: 22 radius: 11 anchors.top: parent.top anchors.topMargin: -3 border.color: "black" } } contentItem: Text { text: control.text font: control.font opacity: enabled ? 1.0 : 0.3 color: Constants.XWHITE verticalAlignment: Text.AlignVCenter leftPadding: control.indicator.width + control.spacing } }
-
Hi, Thank you!
I helps me by 50% :-) . Your solution can not the switch "turns on" , but it still "turns it off".
:-(