Answer the question
In order to leave comments, you need to log in
How to load text from file into TextArea by line break?
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
TextArea {
id: editor
text: "G0 X11 Y0"
font.pixelSize: 10
textFormat: TextEdit.RichText
selectByMouse: true
function loadTextFile(fileUrl){
var xhr = new XMLHttpRequest;
xhr.open("GET", fileUrl);
xhr.onreadystatechange = function () {
if(xhr.readyState === XMLHttpRequest.DONE){
var response = xhr.responseText;
console.log(response)
editor.text = response
}
}
xhr.send();
}
Component.onCompleted: {
loadTextFile("../../res/gcode/example1.gcode")
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question