Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to elide text in TextEdit

    QML and Qt Quick
    1
    2
    1031
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Q
      Qyrychen95 last edited by

      hi All!
      There is Qml model and TableView in my application.
      TextEdit is used in delegate for text displaying (I use this element because I will use QSyntaxHighlighter with it)
      Also I use wrapMode: Text.NoWrap

      After column width changing I want get elide string (like ThisIsATex... for example)
      I use TextMetrics for text eliding (http://doc.qt.io/qt-5/qml-qtquick-te...tml#width-prop)

          onWidthChanged: {
                                  textMetrics.text = delegateTextEdit.text
                                  textMetrics.elideWidth = delegateTextEdit.width - 10
                                  var str = textMetrics.elidedText
                                  console.debug(str)
           
                                  //delegateTextEdit.text = str
                              }
      

      Problem:

      • on width changing I can see correct elide text in console (in TableView it doesn't appear)
      • after last line uncommented I see text only at first column in my table. Yes, text is elided but only in one way

      I cannot find how to attach screenshots (you can get it here http://www.qtcentre.org/threads/65095-How-to-elide-text-in-TextEdit)

      1 Reply Last reply Reply Quote 0
      • Q
        Qyrychen95 last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • First post
          Last post