33 lines
591 B
QML
33 lines
591 B
QML
import QtQuick
|
|
|
|
ListView {
|
|
id: root
|
|
model: ListModel {
|
|
id: logModel
|
|
ListElement {
|
|
message: ""
|
|
}
|
|
}
|
|
delegate: Text {
|
|
width: ListView.view.width
|
|
text: message
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
|
|
function append(message){
|
|
let item = {
|
|
message: message
|
|
};
|
|
logModel.append(item)
|
|
if(root.atYEnd){
|
|
Qt.callLater(()=>{
|
|
root.positionViewAtEnd() })
|
|
}
|
|
}
|
|
|
|
function clear(){
|
|
logModel.clear()
|
|
}
|
|
}
|