Anchors problem with several texts
-
Hello,
I try to align text fragments of different sizes (point). I thought if I anchor 2 elements at the top of each other, they would start at the same y-value. But it seems in texts there are existing special rules. The following example shows what I intend to do.
@
Rectangle
{
width: 360
height: 360Text { id: t1 x: 50 y: 40 text: "A" font.family: "Verdana"; font.weight: Font.Normal font.pointSize: 40 } Text { id: t2 text: "B" font.family: "Verdana"; font.weight: Font.Normal font.pointSize: 20 anchors.bottom: t1.bottom anchors.left: t1.right } Text { id: t3 text: "C" font.family: "Verdana"; font.weight: Font.Normal font.pointSize: 10 anchors.top: t2.top anchors.left: t2.right }}
@Edit: fixed code indentation for improved readability; Andre
-
Hmm ... strange. I thought I made this test as well. :/
It works like expected for the first 2 letters. So thank you again!But while t1 and t2 are sitting now on the same baseline, I still don't see a way to align t3 to the "topline" of letter t2 (both letters start on the same y-value). I tried something like this for t3:
@
anchors.baseline: t2.baseline
anchors.baselineOffset: -( t2.paintedHeight - paintedHeight )
@But don't work.
-
Of course, here is the image for baseline usage t1/t2 and code snippet from last post for t2/t3 :)
!http://www.treggs.de/img/Image1.png(Baseline image)!
Edit: fixed image tag. Image tag gets screwed if you don't enter an alternative text; Andre