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 13.1k 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 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 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 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
        • lajtuL Offline
          lajtuL Offline
          lajtu
          wrote on last edited by
          #4

          Use:

          elide: Text.ElideRight
          :)

          1 Reply Last reply
          3
          • ibiaI Offline
            ibiaI Offline
            ibia
            wrote on 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