无法在 RowLayout 中调整 TextField 的大小

TextField can't be resized within RowLayout

TextField 放入 RowLayout 后,我无法再调整 TextField 的大小。我尝试为 TextField 设置 anchors 以填充 RowLayout 的左侧及其中心,使其成为 RowLayoutwidth 的一半,但它变成了只比它的一半大。

现在我正在尝试将 TextFieldwidth 绑定到 RowLayoutwidth,但元素仍然没有调整大小。当我从其父级中取出 TextField 时,它会很好地调整大小。这是 Qt 的错误还是我忘记了什么?

这是我得到的照片:

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2

ApplicationWindow {
    visible: true
    width: 210
    height: 160

    RowLayout {
        x: 15
        y: 21
        width: 181
        height: 23

        TextField {
            id: first
            width: parent.width /2
            height: parent.height
        }

        TextField {
            id: second
            width: parent.width /2
            height: parent.height
        }
    }

    TextField {
        id: result
        x: 15
        y: 55
        width: 181
        height: 23
        placeholderText: qsTr("Result")
    }
}

正如@KernelPanic 所说,我在 TextField 上使用了 Layout.fillWidth,一切开始正常工作。

根据 Qt 文档:

If this property is true, the item will be as wide as possible while respecting the given constraints. If the property is false, the item will have a fixed width set to the preferred width. The default is false, except for layouts themselves, which default to true.

respecting the given constraints

正是我所需要的