Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

anchors.baseline in QML

Tags:

c++

qt

qml

There is some Defination confused me... I found a Text's anchors.baseline is different from Rectangle's.. Why ? what is the defination of baseline ? Thank you ...

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's baseline is top, and Text's baseline is bottom?

like image 865
Mr.Tu Avatar asked Oct 27 '25 18:10

Mr.Tu


1 Answers

The baseline corresponds to the imaginary line on which text would sit. For items with no text it is the same as top.

like image 177
shofee Avatar answered Oct 29 '25 08:10

shofee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!