-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.qml
79 lines (76 loc) · 2.18 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import QtQml 2.12
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
Window {
id: root
width: 640
height: 480
visible: true
title: qsTr("QML Logger")
ColumnLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 6
RowLayout {
spacing: 6
Layout.fillWidth: true
Layout.preferredHeight: 30
ComboBox {
id: log_level
implicitWidth: 90
implicitHeight: 30
model: ["Debug", "Info", "Warning", "Critical"]
}
TextField {
id: log_edit
Layout.fillWidth: true
Layout.preferredHeight: 30
implicitHeight: 30
selectByMouse: true
text: "QML日志信息"
}
Button {
id: log_enter
implicitWidth: 60
implicitHeight: 30
text: "Log"
onClicked: {
// 没有 console.fatal
switch (log_level.currentIndex)
{
case 0: console.debug(log_edit.text); break;
case 1: console.info(log_edit.text); break;
case 2: console.warn(log_edit.text); break;
case 3: console.error(log_edit.text); break;
}
}
}
}
ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
TextArea {
id: log_view
wrapMode: TextArea.WordWrap
textFormat: TextArea.RichText
selectByMouse: true
background: Rectangle {
border.color: "gray"
}
}
}
}
Connections {
target: logManager
// 低版本的连接方式
// onNewLog: {
// log_view.append(logManager.richText(msgType, log))
// }
function onNewLog(msgType, log)
{
log_view.append(logManager.richText(msgType, log))
}
}
}