QML的Gridlayout布局

这篇博客介绍了如何在QML中使用GridLayout进行界面布局,详细展示了如何设置行列数、间距,并通过实例演示了创建多个TextField输入框的布局方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Grid网格布局就是在网格上面安置Item,可以通过设置他的rows, columns来控制网格的行列书,Grid默认的是4*4的, Grid默认的流是LeftToRight, 从左到右安置Item,一行放满再放到下一行中,可以通过修改Grid的flow属性来控制他,比如修改成TopToBottom。下面来看一下我的qml的Grid实现。

GridLayout{
id: printview
anchors.rightMargin:50;
anchors.bottomMargin:40;
anchors.leftMargin:50;
anchors.topMargin:20;
columns: 4
rows:5
rowSpacing: 5;
columnSpacing: 5;

anchors.fill: parent
Label{
id:voucheridLabel
text: “提煤单号”
font.pointSize: 20
}
TextField {
id: voucheridField
Layout.fillWidth: true
width: 300
font.pointSize: 20
horizontalAlignment: Text.AlignHCenter

color: “white”

background: Rectangle {
color: Qt.rgba(0.1, 0.1, 0.1, 0.3)
border.color: parent.enabled ? “white” : “gray”
border.width: 1
radius: 3
}
}

Label{
id:vehicleNumLabel
text: “车 牌 号”
font.pointSize: 20
}
TextField {

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值