脚本与 Python API

MQWidget.WidgetBase · 控件基类

本页目录
  1. 属性
  2. 方法
  3. addChild(child)
  4. insertChild(child, index)
  5. removeChild(child)
  6. indexOfChild(child)
  7. getJustSize([max_width, max_height])
  8. repaint([immediate])
  9. clientToScreen(x, y)
  10. screenToClient(x, y)
  11. clientToClient(x, y, target)

所有控件的基类。

属性#

读取(get) 写入(set) 类型 名称 说明
x int id 控件 ID
x x string name 控件名称(不可覆盖)
x x int tag 任意值
x x bool enabled 启用状态
x x bool visible 可见性
x x string horzLayout 水平布局状态
[auto] 自动
[fixed] 按像素设置宽度
[hintsize] 按建议尺寸设置宽度
[fill] 填满全部宽度
[free] 手动指定位置和大小
x x string vertLayout 垂直布局状态
[auto] 自动
[fixed] 按像素设置宽度
[hintsize] 按建议尺寸设置宽度
[fill] 填满全部宽度
[free] 手动指定位置和大小
x x bool width 宽度
x x bool height 高度
x x float fillRateX 宽度填充比例
x x float fillRateY 高度填充比例
x x float fillBeforeRate 前置空间填充比例
x x float fillAfterRate 后置空间填充比例
x x float inSpace 子控件之间的间距
x x float outSpace 所有子控件外侧的间距
x x float hintSizeRateX 建议宽度
x x float hintSizeRateY 建议高度
x x int cellColumn 矩阵框架的列数
x x string hintText 工具提示中显示的文本

方法#

成员 说明
addChild 添加子控件。
insertChild 在指定索引处插入子控件。
removeChild 移除子控件。
indexOfChild 获取子控件索引。
getJustSize 获取能够容纳所有子控件的大小。
repaint 重绘控件。
clientToScreen 将客户区坐标转换为屏幕坐标。
screenToClient 将屏幕坐标转换为客户区坐标。
clientToClient 将客户区坐标转换为屏幕坐标。

addChild(child)#

添加子控件。

参数:
MQWidget.WidgetBase child - 子控件
返回值:
int - 子控件索引

insertChild(child, index)#

在指定索引处插入子控件。

参数:
MQWidget.WidgetBase child - 子控件
int index - 插入位置的索引
返回值:
int - 子控件索引

removeChild(child)#

移除子控件。

参数:
MQWidget.WidgetBase child - 子控件

indexOfChild(child)#

获取子控件索引。

参数:
MQWidget.WidgetBase child - 子控件
返回值:
int - 子控件索引
[-1] 不是子控件

getJustSize([max_width, max_height])#

获取能够容纳所有子控件的大小。

参数:
int max_width - 控件最大宽度
int max_height - 控件最大高度
返回值:
list{int,int} - 包含宽度和高度的列表

repaint([immediate])#

重绘控件。

参数:
bool immediate - 是否立即重绘,或稍后重绘

clientToScreen(x, y)#

将客户区坐标转换为屏幕坐标。

参数:
int x - 客户区 X 坐标
int y - 客户区 Y 坐标
返回值:
list{int,int,bool} - 包含 X 坐标、Y 坐标和结果的列表

screenToClient(x, y)#

将屏幕坐标转换为客户区坐标。

参数:
int x - 客户区 X 坐标
int y - 客户区 Y 坐标
返回值:
list{int,int,bool} - 包含 X 坐标、Y 坐标和结果的列表

clientToClient(x, y, target)#

将客户区坐标转换为屏幕坐标。

参数:
int x - 客户区 X 坐标
int y - 客户区 Y 坐标
MQWidget.WidgetBase target - 目标控件
返回值:
list{int,int,bool} - 包含目标客户区 X 坐标、Y 坐标和结果的列表
输入关键词,查找手册中的内容。