I have to use Qt show the context of a file, whose size is 70M, but is so slow that it takes several minutes to display.
QFile file("farey.txt");
file.open(QFile::ReadOnly | QFile::Text);
QTextStream ReadFile(&file);
while (!ReadFile.atEnd()) {
QString line = ReadFile.readLine();
ui->Output->append(line);
}
file.close();
Output is TextEdit, can anyone give me some help to make it faster?
Can I use Qt to dispatch a default system editor to open the file??
If you want to display your file as plain text, the widget QPlainTextEdit is better then QTextEdit. It is optimized to handle large documents, for example see QTextEdit vs QPlainTextEdit
QTextEditis an advanced WYSIWYG viewer/editor supporting rich text formatting using HTML-style tags.
QTextEditcan display images, lists and tables.
QPlainTextEditis an advanced viewer/editor supporting plain text.
QPlainTextuses very much the same technology and concepts asQTextEdit, but is optimized for plain text handling.
It is possible to open a file by default system file handler using QDesktopServices, for example:
QDesktopServices::openUrl(QUrl::fromLocalFile("file_path"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With