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. How to cut off text using QML Text element?
Forum Updated to NodeBB v4.3 + New Features

How to cut off text using QML Text element?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 4 Posters 12.9k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bkamps
    wrote on 18 Oct 2011, 09:33 last edited by A Former User
    #1

    Hi,

    I think i'm overlooking something because there has to be a simple solution for my problem.

    I have a text element:

    @
    Text {
    text : "veryloonnnnnnnnnnnnnnggggggggggggggggggggggggtext"
    width: 100
    }
    @

    How can I "cut off" the text so everything over width 100 won't be visible ( so only "verylon" or something will be shown ) ?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on 18 Oct 2011, 09:46 last edited by
      #2

      If you set clip:true on the text item, the element will not draw outside of it rectangular bounds. Alternatively, if you want the text to use elipsis (...) you can set the text elide mode to tell it how to crop the text to fit.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bkamps
        wrote on 18 Oct 2011, 09:54 last edited by
        #3

        Thanks a lot Jens, I have used the clip property of text element to "cut off" the text!

        I have tried elide before but it didn't cut the tex on the right side..

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lajtu
          wrote on 13 Dec 2017, 14:57 last edited by
          #4

          Use:

          elide: Text.ElideRight
          :)

          1 Reply Last reply
          3
          • I Offline
            I Offline
            ibia
            wrote on 26 Dec 2017, 21:18 last edited by
            #5

            Mark the subject as solved.

            1 Reply Last reply
            0

            • Login

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