QML中如何在多个RowLayout之间添加Splitter?
在QML的多个RowLayout之间添加Splitter
要在两个RowLayout之间添加可拖动的分隔组件,只需将这两个RowLayout嵌套到Splitter容器中,并配置必要的布局属性即可。修改后的完整代码如下:
Splitter { // 设置垂直方向分隔,适配两个RowLayout上下排列的场景 orientation: Qt.Vertical anchors.fill: parent RowLayout { Layout.fillWidth: true Layout.fillHeight: true // 原RowLayout内的业务内容 } RowLayout { Layout.fillWidth: true Layout.fillHeight: true // 原RowLayout内的业务内容 } }
核心要点
Splitter是Qt Quick原生组件,会自动在子元素之间生成可拖动的分隔条- 给每个RowLayout设置
Layout.fillWidth: true和Layout.fillHeight: true,确保它们能跟随Splitter的拖动动作自动调整尺寸 - 若需要横向分隔(两个RowLayout左右排列),只需将
orientation属性改为Qt.Horizontal
内容的提问来源于stack exchange,提问作者Jeyanth Inba
相关产品推荐
相关产品推荐

