在“uint isWidget:1;”中的colon(:)运算符的含义是什么?在Qt? [英] What is the meaning of colon (:) operator in "uint isWidget : 1;" in Qt?

查看:638
本文介绍了在“uint isWidget:1;”中的colon(:)运算符的含义是什么?在Qt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

uint isWidget:1;中的colon(:)运算符的含义是什么?在Qt?是uint isWidget:1;相当于uint isWidget(1)?

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

Qt中的代码是

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 
};


推荐答案

这是C struct 符号 - 您可以使用属性名称后面的:numBits 以位为单位指定整数字段的大小。

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.

我必须假设在C ++类中可以使用相同的语法(我是一个C的人,但我相信这是在C ++做同样的事情)

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

这篇关于在“uint isWidget:1;”中的colon(:)运算符的含义是什么?在Qt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆