How to cut off text using QML Text element?
-
wrote on 18 Oct 2011, 09:33 last edited by A Former User
Hi,
I think i'm overlooking something because there has to be a simple solution for my problem.
I have a text element:
@
Text {
text : "veryloonnnnnnnnnnnnnnggggggggggggggggggggggggtext"
width: 100
}
@How can I "cut off" the text so everything over width 100 won't be visible ( so only "verylon" or something will be shown ) ?
-
wrote on 18 Oct 2011, 09:46 last edited by
If you set clip:true on the text item, the element will not draw outside of it rectangular bounds. Alternatively, if you want the text to use elipsis (...) you can set the text elide mode to tell it how to crop the text to fit.
-
wrote on 18 Oct 2011, 09:54 last edited by
Thanks a lot Jens, I have used the clip property of text element to "cut off" the text!
I have tried elide before but it didn't cut the tex on the right side..
-
wrote on 13 Dec 2017, 14:57 last edited by
Use:
elide: Text.ElideRight
:) -
wrote on 26 Dec 2017, 21:18 last edited by
Mark the subject as solved.