PDA

View Full Version : Load textfile content into a textEdit



gt.beta2
3rd March 2009, 19:42
Hi,
I wrote this sample code to test the situation described on the title:

Dialog::Dialog(QWidget *parent)
: QDialog(parent), ui(new Ui::DialogClass)
{
ui->setupUi(this);
QFile A;
QTemporaryFile B;
A.setFileName(ui->filenameA->text());
//B.setFileName(ui->filenameB->text());
A.open(QFile::ReadOnly);
B.open();

QTextStream in(&A);
QTextStream out(&B);

QString line;
do {
line = in.readLine();
out << "##" << line << endl;
} while (!line.isNull());
ui->textEditA->setPlainText(in.readAll());
A.close();
B.close();
}

in line 20 i want the content of the stream to be loaded into textEditA.
Where am i thinking wrong here?

Thanks

gt.beta2
3rd March 2009, 22:57
I get it ... i have to reposition myself in the beginning of the stream :p