【问题标题】:QT QML Text ElideRight/Wrap combination behaviorQT QML Text ElideRight/Wrap 组合行为
【发布时间】:2021-01-04 17:09:37
【问题描述】:

尝试在 qt qml 中格式化换行文本框,我有以下内容:

   Text {
        width: 100
        height: 100
        text: "Lorem ipsum dolor sit amet, his at tantas oportereintellegebat"
        wrapMode: Text.Wrap
        elide: Text.ElideRight
        maximumLineCount: 3
    }

导致:

Lorem ipsum
dolor sit amet, his
at tanta...

这里的省略非常激进。理想情况下,我会在文本框中尽可能多地输入最后一个单词:

Lorem ipsum
dolor sit amet, his
at tantas oporte...

当我将 wrapMode 更改为 WrapAnywhere 时,我可以得到什么。

Lorem ipsum dolo
r sit amet, his at ta
ntas oportereint...

将单词切成两半有点过于激进。我怎样才能做到不将单词切成两半,还要填写文本框的远端?

【问题讨论】:

    标签: qt qml


    【解决方案1】:

    Text.WordWrap - 仅在字边界上进行换行。如果一个词是 太长,contentWidth 会超过设定的宽度。
    https://doc.qt.io/qt-5/qml-qtquick-text.html#wrapMode-prop

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-16
      • 2011-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多