I again tried to display my text file in ...but now in textbrowser...this time my program ran succcessfully and I and i browsed to my text file and it did displayed the content of my textfile but..ERROR:nly single line is diplayed....please suggest me ...to improve my code
void MainWindow::on_pushButton_clicked()
{
QString filename
= QFileDialog::getOpenFileName(this, tr
("wew"),
"",tr
("allfiles(*.txt)"));
{
while (!in.atEnd())
{
line = in.readLine();
ui->textBrowser->setText(line);
//ui->textEdit->setPlainText(line);
}
file.close();
}
}
void MainWindow::on_pushButton_clicked()
{
QString filename = QFileDialog::getOpenFileName(this, tr("wew"),"",tr("allfiles(*.txt)"));
QFile file(filename);
if(file.open(QIODevice::ReadOnly | QIODevice::Text));
{
QTextStream in(&file);
QString line;
while (!in.atEnd())
{
line = in.readLine();
ui->textBrowser->setText(line);
//ui->textEdit->setPlainText(line);
}
file.close();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks