Results 1 to 14 of 14

Thread: segfault on qtextstream

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default need help to write text to a file

    hey all,
    First I open a file "cutePOSinvoice.html" that I read with
    QTextStream, then I put the content in a QString "templateoutput ". I
    replace some text in templateoutput with some other string and then
    create a new file "output.html" to write the new templateoutput string
    into. Everything works fine except the writing cause when I remove it the app doesn't crash, it might be due to something else but I'm pretty clueless. Any idea what
    I'm doing wrong? thanx in advance, here is the code:
    Qt Code:
    1. QFile invoice("cutePOSinvoice.html");
    2. if (!invoice.open(QIODevice::ReadOnly | QIODevice::Text))
    3. return;
    4.  
    5. QTextStream in(&invoice);
    6. QString templateoutput = in.readAll();
    7.  
    8. qDebug() << templateoutput;
    9. invoice.close();
    10. QString clientIDinvoice = getAccountID();
    11.  
    12. templateoutput.replace (QString("$ClientID"),clientIDinvoice );
    13. QFile data("output.html");
    14. if (data.open(QFile::WriteOnly)) {
    15. QTextStream out(&data);
    16. out << templateoutput;
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by patcito; 25th February 2006 at 04:41.

Similar Threads

  1. Segfault in Construkctor of QCoreApplication?!?
    By schulze in forum Qt Programming
    Replies: 1
    Last Post: 6th November 2008, 11:50
  2. when close QTextStream
    By mattia in forum Newbie
    Replies: 1
    Last Post: 24th November 2007, 13:17
  3. QTextStream + QFile issue
    By trueneo in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2007, 15:16
  4. Create QTextStream
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2007, 20:25
  5. reading from QTextStream
    By matyi52 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 14th December 2006, 07:26

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.