Text Alignment
Solved
QML and Qt Quick
-
Hi All,
I want to align text to the center of rectangle if the length of the string is less.
Or else i need to make the text to fit into the parent.How do I achieve it.
Below is the code that tried, But unable to align it to center when the text is less in lengthRectangle{ width:200 height:60 color: "lightgray" Text{ anchors.fill: parent font.pixelSize: 24 text: "Some Some" /*"SOme Text SOme Text SOme Text SOme text sdjhsakcjcsdkvkjds"*/ fontSizeMode: Text.Fit minimumPixelSize: 10 wrapMode: Text.WordWrap horizontalAlignment: parent.horizontalCenter verticalAlignment: parent.verticalCenter } }
Edit[j.hilk]:added missing code tags for better reading
-
hi @Madesh-R
that are not the correct binding for text alignment
Rectangle{ width:200 height:60 color: "lightgray" Text{ anchors.fill: parent font.pixelSize: 24 text: "Some Some" /*"SOme Text SOme Text SOme Text SOme text sdjhsakcjcsdkvkjds"*/ fontSizeMode: Text.Fit minimumPixelSize: 10 wrapMode: Text.WordWrap horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } }