Results 1 to 4 of 4

Thread: Write on a text file from QString

  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Write on a text file from QString

    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 is Error without line nuber which says:
    mainwindow.o ERROR1
    !!

    This is one of my tries:
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QString str = "Malek";
    4. QFile file ("hello");
    5. QTextStream outstream(&file);
    6. outstream << str;
    7. }
    To copy to clipboard, switch view to plain text mode 

    Can you help me ,Please.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Write on a text file from QString

    You might want open the file for writing. See the QFile and QTextStream detailed description in the docs.

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Write on a text file from QString

    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.

  4. #4
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Write on a text file from QString

    Thanks Lykurg.
    Thanks SixDegrees.

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

Similar Threads

  1. How to write something on a text file on a certain line?
    By Bong.Da.City in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2010, 21:01
  2. Write one value per line in text file
    By babygal in forum Newbie
    Replies: 11
    Last Post: 1st December 2010, 06:47
  3. Replies: 2
    Last Post: 2nd November 2010, 05:15
  4. How to write ByteArray into a text file?
    By babygal in forum Newbie
    Replies: 4
    Last Post: 11th October 2010, 04:19
  5. Write colored text
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2010, 12:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.