2 Attachment(s)
Re: QListWidget first line in file not read
Hallo,
my program reads an txt file to a QListWidget, but the first row in the txt file is not shown when i open it. All the other rows are shown, except line 1.
Also you can see that there is an empty line after last filled row. in the txt there is no line or space or tab after "9".
Code:
void MainWindow::on_btnRead_clicked()
{
QMessageBox::warning(this,
"..",
"keine datei gefunden");
return;
}
while (!text.isNull()) {
text = in.readLine();
ui->listWidget->addItem(text);
}
file.close();
}
txt:
Attachment 13421
output in program:
Attachment 13422
Added after 1 50 minutes:
Code corrected, now it works:
Code:
void MainWindow::on_btnRead_clicked()
{
QMessageBox::warning(this,
"..",
"keine datei gefunden");
return;
}
while (!in.atEnd()) {
text = in.readLine();
ui->listWidget->addItem(text);
}
file.close();
}