如何检测文本何时被省略 [英] How to detect when Text gets elided
本文介绍了如何检测文本何时被省略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 UI 包含一个带有
My UI contains a Text field with
horizontalAlignment: Text.AlignJustify
maximumLineCount: 5
wrapMode: TextEdit.WordWrap
elide: Text.ElideRight
当文本不适合时,最后一行应该以... MORE"结尾,其中MORE"应该是可聚焦的.这可能是一个单独的文本字段,其中可见性由文本是否被省略来控制.
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?
推荐答案
当一个 Text
被省略时,它是 截断
.这是一个简单的例子:
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"
}
这篇关于如何检测文本何时被省略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文