PDA

View Full Version : Write on a text file from QString



Malek
21st December 2010, 23:16
Hi guys ...

I just want to write on a text file from QString and view this file for the user.
I tried again and again.And saw the links which the forum suggest but no output.
The problem that make me angry :mad: is Error without line nuber which says:
mainwindow.o ERROR1
!!

This is one of my tries:

void MainWindow::on_pushButton_clicked()
{
QString str = "Malek";
QFile file ("hello");
QTextStream outstream(&file);
outstream << str;
}

Can you help me ,Please.

Lykurg
21st December 2010, 23:31
You might want open the file for writing. See the QFile and QTextStream detailed description in the docs.

SixDegrees
21st December 2010, 23:39
Another note: if you compile in 'release' mode, your error messages may not have information like source line numbers available, depending on the system and compiler used. During development, you should be building in 'debug' mode to ensure that more detailed information is made available.

Malek
27th December 2010, 19:27
Thanks Lykurg.
Thanks SixDegrees.

The problem has been solved. I will put the soln here soon.