问题
My UI contains a Text field with
horizontalAlignment: Text.AlignJustify
maximumLineCount: 5
wrapMode: TextEdit.WordWrap
elide: Text.ElideRight
When the text does not fit, the last line should end with "... MORE" where "MORE" should be focusable. This will probably be a separate Text field where the visibility is controlled by whether or not the text is elided.
But how can I detect when a Text gets elided?
回答1:
When a Text
gets elided, it is truncated. Here's a simple example:
Text {
id: longText
width: 100
elide: Text.ElideRight
text: "this is a long long long long string"
}
Text {
visible: longText.truncated
anchors.left: longText.right
text: "More"
}
来源:https://stackoverflow.com/questions/39019822/how-to-detect-when-text-gets-elided