QML中的anchors.baseline

Mr.*_*.Tu 3 c++ qt qml

有一些Defination让我感到困惑......我找到了一个Text的anchors.baseline与Rectangle的不同.为什么?什么是基线的定义?谢谢 ...

Item {
    width: 400; height: 200

    Rectangle {
        y:20
        id: rectangle
        width: 80; height: 80
        color: "red"
    }

    Text {
        text: "Hello World!"
        anchors.baseline: rectangle.baseline
        anchors.left: rectangle.right
    }
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 Rectangle的基线是top,Text的基线是底部?

sho*_*fee 7

基线对应于文本所在的虚线.对于没有文字的项目,它与顶部相同.