QT qml布局讲解

正常简单qml设计界面是分为上中下,菜单栏为上,内容栏为中,尾部栏为下。

所以正常是在Application窗口无布局上设置纵向布局ColumnLayout。

使用anchors.fill填充窗口,使用在columnlayout里面继承窗口。

然后在菜单栏中使用方形容器Rectangle。这使用RowLayout布局横向布局,里面添加按钮,文本,菜单等里面可以适当进行空间填充。

Rectangle使用anchors.fill进行填充,然后RowLayout进行布局用Layout.prferredheight和layout.preferredwidth进行布局然后添加控件

菜单栏里面填充是item{layout.fillwidth:true}进行填充。

中间内容栏使用跳转页面控件进行跳转

复制代码
 StackView {
                Layout.fillWidth:true;
                Layout.fillHeight:true;
                id: stackView
                //anchors.fill: parent
                //Layout.fillWidth: true;
                //Layout.fillHeight: true;
                initialItem: Qt.resolvedUrl("second.qml")
            }

尾部栏通过Rectangle方形容器进行设置布局

首先方形容器在ColumnLayout布局中,所以

Layout.preferredwidth和Layout.preferredHeight设置高度和宽度。

然后用RowLayout横向布局进行控件的布局。

相关推荐
小鱼仙官17 小时前
Qt 主界面弹出分界面
开发语言·qt
誰能久伴不乏1 天前
用 UDP 做一条“可靠“的控制通道
c++·qt·网络协议·udp
Bczheng11 天前
VS2022 安装MFC和QT
c++·qt·mfc
会编程的小孩1 天前
8.19号函数
qt
蓝祁子yoky2 天前
Qt学习日记 Day15:网络编程(二)- UDP基础
网络·qt·学习
读书札记20222 天前
Qt UTF-8和UTF-8(BOM)
开发语言·qt
ShineWinsu2 天前
对于Qt:QProgressBar常见属性的解析
开发语言·c++·qt·进度条·gui·定时器·qprogressbar
ShineWinsu2 天前
对于Qt:QLCDNumber常见属性以及QTimer的解析
服务器·数据库·c++·qt·gui·qtimer·qlcdnumber
听风吹等浪起3 天前
第26章:ViT+InceptionDW+FocalLoss改进|CT骨折影像二分类完整Pytorch实现(含PyQt5推理GUI)
pytorch·qt·分类
ShineWinsu3 天前
对于Qt:QRadioButton常见属性以及QButtonGroup的解析
数据库·c++·qt·microsoft·gui·qradiobutton·qbuttongroup