Results 1 to 2 of 2

Thread: writing bits

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Question writing bits

    I need to make a file with 3 bits (not bytes) in it: 0,1,0

    Note that the number of bits is not multiplicate of 4. I don't want to wait until the byte buffer gets full.

    I was wondering if Qt has anything specifically for writing
    bits into binary files?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: writing bits

    General Filed (storead/memory in general) will deal as byte as minimum unit of operation. So if you want to store just 3 bits, there is no other way by as to save the complete byte. There is nothing special Qt can do this case.

    One byte is minimum you one write. This applies to both binay files/ text files, in fact binay/text is just to specify how read/write the file, at the core (OS -> Hard drive) every thing is written as binay data.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    timmu (7th January 2013)

Similar Threads

  1. Replies: 2
    Last Post: 23rd October 2015, 13:29
  2. Application 32/64 bits with VS2005/Qt 4.3
    By mourad in forum Installation and Deployment
    Replies: 0
    Last Post: 21st February 2012, 10:39
  3. can't set serial port data bits
    By yyiu002 in forum Qt Programming
    Replies: 6
    Last Post: 23rd June 2010, 22:28
  4. QImage::bits() overloaded function
    By s410i in forum Qt Programming
    Replies: 3
    Last Post: 9th December 2009, 19:50
  5. QImage-Greyscale-8-bits-pixel
    By Ivan Labrador in forum Newbie
    Replies: 5
    Last Post: 3rd August 2008, 00:08

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.