Results 1 to 3 of 3

Thread: Write NULL character to a file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Write NULL character to a file

    Hello,

    I have try to find the answer, but didn't have found one. I have a small problem to write NULL character to a file, the problem is that the character is not write.

    Could somebody help me ?

    I have tried with QDataStream but It's add many NULL char that I don't want.

    Thanks.


    This is the code that I use :

    Qt Code:
    1. QFile file("out.txt");
    2. if (!file.open(QIODevice::WriteOnly))
    3. return;
    4.  
    5. QRgb* rgb = (QRgb*)image.scanLine(0);
    6.  
    7. for (int x = 0; x < image.width(); x++)
    8. {
    9. int AlphaValue = qAlpha(rgb[x]);
    10. int RedValue = qRed(rgb[x]);
    11. int GreenValue = qGreen(rgb[x]);
    12. int BlueValue = qBlue(rgb[x]);
    13.  
    14.  
    15. QString AlphaAscii ((QChar)AlphaValue);
    16.  
    17. file.write(qPrintable(AlphaAscii));
    18.  
    19. //file.write((const char *)AlphaAscii.toAscii());
    20.  
    21. }
    22.  
    23. file.close();
    To copy to clipboard, switch view to plain text mode 
    Last edited by madshiva; 17th October 2011 at 16:13.

Similar Threads

  1. Null character transmission in QTcpSocket
    By Manish.S in forum Qt Programming
    Replies: 4
    Last Post: 18th June 2010, 07:31
  2. QFile - QDataStream read and write each character
    By nhs_0702 in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2010, 19:03
  3. Character by Character (Unicode?) File Reading
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2009, 15:28
  4. NUll character output for combobox index
    By mdskpr778 in forum Qt Programming
    Replies: 2
    Last Post: 8th October 2008, 18:22
  5. How to terminate NULL character ?
    By merry in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2008, 20:01

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
  •  
Qt is a trademark of The Qt Company.