I am posting because I want a text the be wrap into a rectangle (if the text is too long, it will be cut and the end of it won't be display) For now I tried with :
Rectangle {
id: form
property alias px: form.x
property alias py: form.y
property alias pheight: form.height
property alias pwidth: form.width
property ItemControl itemControl
color: itemControl.backgroundColor
border.width: 1
border.color: itemControl.color
radius: 1
Text {
id: text_field
height: parent.height
width: parent.width
anchors.centerIn: parent
text:itemControl.text
color: itemControl.color
font.pixelSize: 16
font.family: robotoMono.name
font.bold: false
wrapMode: text_field.WordWrap
maximumLineCount: 1
}
}
But I don't have the expected result. The text is still continuing after the end of the rectangle. Does anyone knows how to compel the text into the rectangle ?
You used Text.WordWrap but the text only contains one word (the .
and underscores aren't treated as word separators). Text.Wrap
and Text.WrapAnywhere
may be more appropriate in this case. Moreover, maximumLineCount: 1
will limit Text
to only show one line.
Consider making the font smaller, the rectangle larger, or redesign the UI for this bit.