You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 04:53:21