Marc Van Daele
Marc Van Daele

Reputation: 2734

How to detect when Text gets elided

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?

Upvotes: 1

Views: 4220

Answers (1)

mcchu
mcchu

Reputation: 3369

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"
}

Upvotes: 6

Related Questions