Problems in Implementing Save Feature in Javascript app using Qt
-
wrote on 24 Oct 2011, 05:55 last edited by
I see this is a very old post but would have liked this solution shown for me when I found this post. JavaScript does has problems taking string with line breaks in it. In my case (read kml file stored on local hard drive, pass the string to JavaScript, and use the Google Earth extensions library to parse and display the kml file) the line breaks did not need to be conserved in a file load. To solve this I used:
@
QTextStream in(&file);
QString wholeFile;
QString line = in.readLine();
wholeFile+=line;
while (!line.isNull()) {
line = in.readLine();
wholeFile+=line;
}
@
An alternative method:
@
QByteArray line = file.readAll();
@
does not play well with JavaScript.
21/21