How to detect when Text gets elided

筅森魡賤 提交于 2021-02-11 13:01:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!