[Qt-interest] Question about bitfields

Dan White ygor at comcast.net
Sat Jul 17 14:27:47 CEST 2010


On Jul 17, 2010, at 3:47 AM, Thiago Macieira <thiago at kde.org> wrote:
> On Friday 16. July 2010 10.23.03 Dan White wrote:
>> Thanks, but I can see I did not include enough info in my original
>> question.
>> 
>> I need to, for example, manipulate two boolean bits and a 14-bit signed
>> integer stored in 2 bytes.
>> 
>> In plain old vanilla C, you say :
>> 
>> struct foo
>> {
>> unsigned flag1:1 ;
>> unsigned flag2:1;
>> signed   number:14
>> } ;
> 
> You're saying that you're looking for something more from Qt. From my point of 
> view, the above looks perfect already for what you're trying to do.
> 
> So what more are you looking for?
> 
> Also note that in C++ you can declare other integer types in bitfields, like 
> short, long, long long, enums, etc.
> 
> -- 
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>  Senior Product Manager - Nokia, Qt Development Frameworks
>      PGP/GPG: 0x6EF45358; fingerprint:
>      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Actually, I was not looking for more, personally.  A friend was trying to figure this out and he said he considered QBitArray, but could not see how to do the integer field.  I told him I would ask here.

The folks on this mailing list are great.  Very helpful and very knowledgeable. 

Thanks to all for your responses.

Sent from my iPad





More information about the Qt-interest-old mailing list