c++ - QML 中的 anchors.baseline

标签 c++ qt qml

有些定义让我感到困惑...我发现文本的 anchors.baseline 与矩形的不同.. 为什么?基线的定义是什么?谢谢...

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
    }
}

enter image description here Rectangle 的基线在上,Text 的基线在下?

最佳答案

基线对应于文本所在的假想线。对于没有文本的项目,它与顶部相同。

关于c++ - QML 中的 anchors.baseline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9440534/

相关文章:

c++ - 如何修复( 'vector' : undeclared identifier ) in my header file?

c++ - 从特定填充读取到 C++ 中的最后一行

c++ - 如何将 int 转换为 QString?

qt - 获取ProgressBar来填充矩形qml

c++ - 是否有任何控制循环展开的预处理器指令?

c++ - 字符数组地址和整型数组地址

c++ - 我如何将此信号连接到插槽

c++ - 将 qnetworkaccessmanager 连接到插槽

python - 带有 CheckDelegate 项目的 ListView 在滚动时不保留选中的复选框

c++ - 每个 QML 视频帧的回调