Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Is it possible to use Text.ElideMiddle for each row in a TextArea?

Is it possible to use Text.ElideMiddle for each row in a TextArea?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 382 Views
  • 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.
  • april_heardA Offline
    april_heardA Offline
    april_heard
    wrote on last edited by
    #1

    I would like to have a TextArea (scrollable) that contains multiple lines of text, each ending in a "\n". For each of those lines, I would like to use:

    elide: Text.ElideMiddle
    

    However, TextArea does not contain an elide property, and furthermore, I need it to apply to each newline terminated string individually.

    I do not want to permanently modify the actual text stored. I only want to display it in middle elided format. The lines of text will be URL's and I need to be able to perform operations on the full URL's. Therefore, I don't want to manually shorten them before adding to the TextArea.

    For example, I would like to display 3 urls in a TextArea like this

    https://doc.qt.io/.../qml-qtquick-dragevents.html
    https://forum.qt.io/topic/68405/...text-into-from
    https://forum.qt.io/topic/102632/...es-elidemiddle
    

    But when hovering or clicking on one of them, I want to show/navigate to the full and correct URL.

    Is there an existing or easy solution? I can imagine how a more complex solution might be cooked up (such as even storing an original string and a modified elided string), but I am hoping there is a better way to accomplish this.

    Thanks for any ideas.

    J.HilkJ 1 Reply Last reply
    0
    • april_heardA april_heard

      I would like to have a TextArea (scrollable) that contains multiple lines of text, each ending in a "\n". For each of those lines, I would like to use:

      elide: Text.ElideMiddle
      

      However, TextArea does not contain an elide property, and furthermore, I need it to apply to each newline terminated string individually.

      I do not want to permanently modify the actual text stored. I only want to display it in middle elided format. The lines of text will be URL's and I need to be able to perform operations on the full URL's. Therefore, I don't want to manually shorten them before adding to the TextArea.

      For example, I would like to display 3 urls in a TextArea like this

      https://doc.qt.io/.../qml-qtquick-dragevents.html
      https://forum.qt.io/topic/68405/...text-into-from
      https://forum.qt.io/topic/102632/...es-elidemiddle
      

      But when hovering or clicking on one of them, I want to show/navigate to the full and correct URL.

      Is there an existing or easy solution? I can imagine how a more complex solution might be cooked up (such as even storing an original string and a modified elided string), but I am hoping there is a better way to accomplish this.

      Thanks for any ideas.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #2

      @april_heard
      I would say, this looks like a job for a listview. You can define your own delegate and than elide it. That way only the display is changed, the underlying data is unchanged.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved