Answer the question
In order to leave comments, you need to log in
Why can't text from a file be inserted into QTextEdit?
in general, I write like this, but when you run textEdit by the name code is empty, while code.txt definitely has text. what am I doing wrong?
QFile code("code.txt");
task.open(QIODevice::ReadOnly);
ui->code->insertPlainText(code.readAll());
code.close();
Answer the question
In order to leave comments, you need to log in
QFile code("code.txt");
if (!code.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug() << "file doesn't open";
return ...;
}
ui->code->insertPlainText(code.readAll());
code.close();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question