I'm trying to read a file which has names of servers on individual lines.
I want the output in the text browser to be one line as .*<servername>|<servername>|<servername>.*
I've tried both readings directly to the text browser, and reading to an array and outputting from the array. Both methods result in the text browser displaying each item on its own line. I want all output on the same line. Perhaps it's the append method or the .readLine method that's causing it?
Here's my code:
void MainWindow::on_pushButton_clicked()
{
QString myfile=QFileDialog::getOpenFileName(
this,
tr("Open File"),
"C://",
"Text File (*.txt)"
);
QFile file(myfile);
if(!file.open(QIODevice::ReadOnly))
QMessageBox::information(0,"info",file.errorString());
QTextStream in(&file);
ui->textBrowser->append(".*");
while (!file.atEnd())
{
QString line = file.readLine();
ui->textBrowser->append(line);
ui->textBrowser->append("|");
}
file.close();
}