Row 和 RowLayout 有什么区别? [英] What is the difference between Row and RowLayout?

查看:328
本文介绍了Row 和 RowLayout 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在 Row 中可以正常工作,但在 RowLayout 中无效.为什么?两者有什么区别?

This works as intended with Row, but not with RowLayout. Why? What is the difference between the two?

ApplicationWindow {    
    title: "Testing"
    width: 640
    height: 480

    //RowLayout {
    Row {        
        anchors.fill: parent

        Rectangle {
            id: rect1
            width: parent.width * 0.3
            height: parent.height
            color: "blue"
        }
        Rectangle {
            height: parent.height
            width: parent.width * 0.7
            color: "red"
        }
    }
}

推荐答案

Row 是一个 项目定位器.定位项是在声明性用户界面中管理项位置的容器项.

Row is a Item Positioner. Positioner items are container items that manage the positions of items in a declarative user interface.

RowLayoutQt 快速布局的一部分.它们在声明式用户界面上管理项目的位置和大小,非常适合可调整大小的用户界面.

RowLayout is part of Qt Quick Layouts. They manage both the positions and the sizes of items on a declarative user interface, and are well suited for resizable user interfaces.

带有 RowLayout 的代码应如下所示:

Your code with RowLayout should look like this:

RowLayout{
    anchors.fill: parent
    spacing: 0
    Rectangle{
        Layout.fillHeight: true
        Layout.preferredWidth: parent.width * 0.3
        color: "blue"
    }
    Rectangle{
        Layout.fillHeight: true
        Layout.fillWidth: true
        color: "red"
    }
}

这篇关于Row 和 RowLayout 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆