-
Notifications
You must be signed in to change notification settings - Fork 369
/
Copy pathmain.qml
49 lines (40 loc) · 1.09 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import Test 2.15
MyWindow {
id: root
width: 640
height: 480
visible: true
title: "TestDpi " + root.width + "x" + root.height + " / " + root.dpiRatio
onScreenChanged: {
// 此时 Screen 值可能还没更新,需要点一下测试按钮打印
console.log("screen changed", Screen.devicePixelRatio, Screen.width, Window.width)
}
onDpiRatioChanged: {
console.log("dpi changed", dpiRatio)
}
Row {
anchors.centerIn: parent
spacing: 10
Rectangle {
width: 40
height: 40
border.color: "black"
}
Button {
text: width + "x" + height + " / " + MyWindow.dpiRatio
width: 100 * MyWindow.dpiRatio
height: 40 * MyWindow.dpiRatio
onClicked: {
}
}
Button {
text: "测试"
onClicked: {
console.log("screen", Screen.devicePixelRatio, "mywindow", MyWindow.dpiRatio)
}
}
}
}