add book
This commit is contained in:
40
Qt6QMLBeginnersCode/5.UserInput/6-FocusScope/MButton.qml
Normal file
40
Qt6QMLBeginnersCode/5.UserInput/6-FocusScope/MButton.qml
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
FocusScope {
|
||||
|
||||
width: containerRectId.width
|
||||
height: containerRectId.height
|
||||
property alias color: containerRectId.color
|
||||
|
||||
Rectangle {
|
||||
id : containerRectId
|
||||
width: 300
|
||||
height: 50
|
||||
color: "beige"
|
||||
focus: true
|
||||
|
||||
Text {
|
||||
id : textId
|
||||
anchors.centerIn: parent
|
||||
text: "Default"
|
||||
}
|
||||
|
||||
Keys.onPressed:function(event) {
|
||||
if(event.key === Qt.Key_1)
|
||||
{
|
||||
textId.text = "Pressed on Key1"
|
||||
}else if(event.key === Qt.Key_2)
|
||||
{
|
||||
textId.text = "Pressed on Key2"
|
||||
}else{
|
||||
textId.text = "Pressed on another key : "+ event.key
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user