You should use
void QPlainTextEdit::appendPlainText ( const QString & text ) [slot]
method, link.
Question
I wrote a Program in Qt 5.2.1 that writes some data into a file and now I want to read it and display it. ( in a text edit or any other widget)
Here is my code ( the part I thought is relevant ) -
But i don't get the desires result ... could you look into it and tell me what i an doing wrong
void MainWindow::on_Search_clicked()
{
QString name ;
name = ui->Search_name->text();
QFile readfile("data.txt");
if(!readfile.open(QIODevice::ReadOnly))
{
qDebug() << "error opening file: " << readfile.error();
return;
}
QTextStream instream(&readfile);
QString line = instream.readLine();
// ui->text is a QPlainTextEdit*
ui->text->insertPlainText(line);
readfile.close();
return;
}
Solution