Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of colon (:) operator in "uint isWidget : 1;" in Qt? [duplicate]

What is the meaning of colon (:) operator in "uint isWidget : 1;" in Qt? Is "uint isWidget : 1;" equivalent to "uint isWidget(1)"?

The code in Qt is

QObjectData 
{
  public:
     virtual ~QObjectData() = 0;
     QObject *q_ptr;
     QObject *parent;
     QObjectList children;

     uint isWidget : 1;
     uint pendTimer : 1;
     uint blockSig : 1;
     uint wasDeleted : 1;
     uint ownObjectName : 1;
     uint sendChildEvents : 1;
     uint receiveChildEvents : 1;
     uint inEventHandler : 1;
     uint inThreadChangeEvent : 1;
     uint hasGuards : 1; //true iff there is one or more QPointer attached to this object
     uint unused : 22;
     int postedEvents;
     QMetaObject *metaObject; // assert dynamic 
};
like image 863
Sulla Avatar asked Jan 28 '11 07:01

Sulla


1 Answers

This is part of C struct notation - you can specify the size of an integer field in bits by using a : numBits after the property name.

I must assume that the same syntax can be used in a C++ class (i'm a C guy, but i'm sure that this is doing the same thing in C++)

like image 175
tobyodavies Avatar answered Oct 20 '22 01:10

tobyodavies