在上次的工程上进行修改
Label(标签)
标签是用户不可编辑的文本,可以用来显示信息。
在demo的ui文件中,HelloWorld的label代码声明如下
<object class="GtkLabel" id="label">
<property name="can_focus">False</property>
<property name="label">Hello, World!</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
在cpp文件中
builder->get_widget("label", label);
add(*label);
label->show();
label变量从builder中根据id字符串获取,随后通过add函数添加到容器中(这里是window容器)
Box
Box可以将一些控件打包成一个整体,便于管理ui界面。
打开ui文件,首先尝试用图形界面创建一个box,并分配一个唯一的ID