+ Reply to Thread
Results 1 to 3 of 3

Thread: Filling QBitArray with data

  1. #1
    Join Date
    Apr 2014
    Posts
    28
    Thanks
    13
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Filling QBitArray with data

    I'd like to use QBitArray to store raster data that I have in files. However, the class doesn't seem to have the means to initialize or fill itself from a pre-existing buffer. Am I missing something here?

    Internally, QBitArray uses a private member of class QByteArray. QByteArray has both a deep-copy initializer and a member function that takes a pointer to a pre-existing buffer (that the QByteArray can then access). However, QBitArray doesn't appear to expose its QByteArray.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,437
    Thanks
    21
    Thanked 388 Times in 382 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Filling QBitArray with data

    The usage of QByteArray internally is an implementation detail, not a principal behavior of the QBitArray - that could change in the future, which is why it is not exposed.
    However doing a conversion function from QByteArray to QBitArray is rather a trivial thing to do, just few lines of code.
    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
    Watch these videos, and read his books they are must if you want to write clean code:
    https://sites.google.com/site/unclebobconsultingllc/

    Recommended off-line reading Qt:
    The Foundations of Qt Development (ISBN: 1-59059-831-8)

  3. #3
    Join Date
    Apr 2014
    Posts
    28
    Thanks
    13
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Filling QBitArray with data

    Quote Originally Posted by high_flyer View Post
    The usage of QByteArray internally is an implementation detail, not a principal behavior of the QBitArray - that could change in the future, which is why it is not exposed.
    Yes, I am aware of the usual reasons for not exposing implementation details. However, QBitArray doesn't have similar methods to QByteArray for initialization/fill (in the manner I mentioned). I hoped, in this case, that it would expose the QByteArray.

    Quote Originally Posted by high_flyer View Post
    However doing a conversion function from QByteArray to QBitArray is rather a trivial thing to do, just few lines of code.
    Well, I'd definitely like to see those lines of code

    I've re-read the documentation for both QBitArray and QByteArray and I cannot come up with any way to convert from one to the other.

    Thanks

+ Reply to Thread

Similar Threads

  1. Replies: 9
    Last Post: 27th March 2015, 07:21
  2. Empty QBitArray problem
    By MarkoSan in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2011, 15:06
  3. QBitArray (the smallest unit of them all)
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2007, 14:16
  4. Replies: 5
    Last Post: 25th September 2007, 19:38

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