bounds指边界范围。
clientarea指窗口的显示区域(即放置 子控件的有效区域),一般而言clientarea小于bounds。只有Composite等一些容器类才有ClientArea的说法。一般控件没有。
获取某控件的bounds:getBounds
由于布局有spacing,margin等:所以,很多时候x,y坐标可能不是0,clientarea也相较bounds的width,height小几个像素。
如,某个容器(comp使用的是RowLayout布局。)的ClientArea为
comp ClientArea: Rectangle {0, 0, 54, 28}
但里面放置的button的bounds为(只放置了button一个控件):
button: Rectangle {3, 3, 48, 22}
是因为RowLayout布局默认有上下,左右的margin。
comp marginTop: 3
comp marginHeight: 0
comp marginBottom: 3
comp marginLeft: 3
comp marginWidth: 0
comp marginRight: 3
上下相加,左右相加正好为6像素。button的width,height加上6个像素刚好为comp的clientArea
的width和height
本文详细解释了软件开发中控件的bounds与clientarea的区别。bounds表示控件的边界范围,而clientarea则是控件的有效显示区域。通常clientarea会比bounds小,这是因为布局设置如spacing和margin的影响。
1624

被折叠的 条评论
为什么被折叠?



