[SOLVED]How to limit the text width with the restriction of parent width
-
Hi,
@Label {
id: test
width: 100
height: 30
Text{
color: 'red'
//anchors adjustment
text: qsTr("sometext") //if sometext has 256 characters, lengthy text appears in adjacent controls.
}
}
@How to truncate the test as per label width? I have width in pixels. Want to control text. any idea.
Thanks.
-
Hi,
Set clip: true for Text element.
-
@
Label {
id: test
width: 100
height: 30
Text{
color: 'red'
width: parent.width // The width of the text is same as parent
anchors.centerIn:parent // The text is placed in center of the parent
elide: Text.AlignRight // Show ellipses '...' if text is not able to fit horizontally
text: qsTr("sometext")
}
}@
You should avoid clipping. As per the Performance Considerations And Suggestions document "Clipping is a visual effect, NOT an optimization. It increases (rather than reduces) complexity for the renderer."