开发者

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

This question already has answers here: What does a colon in a struct declaration mean, such as :1, :7, :16, or :32? (3 answers) Closed 7 years ago.

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 receiveChil开发者_JAVA百科dEvents : 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 
};


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++)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜