import QtQuick 2.15
import QtQuick.Controls 2.15
Window {
width: 300
height: 480
// minimumWidth: 300 // 限制窗口放大缩小,控制窗口的大小固定
// minimumHeight: 480
// maximumWidth: 300
// maximumHeight: 480
visible: true
title: qsTr("Hello World")
x: 100
y: 100
id: window
// opacity: 0.9 // 透明度 0-1
// 自定义属性
property int myNum: 1000
onWidthChanged: {
console.log(width)
}
onMyNumChanged: {
console.log(myNum)
}
Button {
id: btn1
x: 100
width: 100
height: 30
text: '修改myNum'
background :Rectangle{
border.color: btn1.focus ? "blue" : "black"
}
onClicked: {
console.log('btn1 clicked')
window.myNum += 10
}
Keys.onRightPressed: {
btn2.focus = true
}
}
Button {
id: btn2
text: 'button2'
y: 100
width: 100
height: 30
background:Rectangle {
border.color: btn1.focus ? "blue" : "black"
}
onClicked: {
console.log('btn2 clicked')
window.myNum += 10
}
Keys.onRightPressed: {
btn1.focus = true
}
}
}