Reputation: 99
I'm building an app that will read in a gcode file. Files range from a few KB to a few hundred MB (but that's rare). After a user selects a file, the program goes through it and reads it line by line. This doesn't take long at all.
I want to display the text of the file I just read in in a QTextEdit widget. Unfortuantely, doing this takes a really long time (a few seconds for even small files).
I've thought about just adding a "loading, please wait" message for the user, but I was wondering if there was a way to speed up the text loading process.
right now my code looks like this:
QTextStream in(gcodeFile); //The file path was given by the user
ui->textEdit->setText(in.readAll());
in.seek(0);
processGcode();
Is there a better way to load a lot of text into a QTextEdit that won't make the app hang?
Note: The issue is not that I'm reading through the file twice. I changed my code so that it did the processing at the same time as adding the text to the QTextEdit, but the whole thing still took too long.
Upvotes: 4
Views: 5754