Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Prevent QLabel from expanding when text length increases

Prevent QLabel from expanding when text length increases

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.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.
  • Q Offline
    Q Offline
    Qt_User72653
    wrote on last edited by
    #1

    I have a horizontal layout with 3 labels where the labels on the left and right have expanding size policies and the label in the center has a fixed size. I want the middle label to always be centered, but when the text of the left or right expands it's pushing the other labels to the right or left.

    Is it possible to have a QLabel truncate text without having to give it a fixed size?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Well its fairly easy to make.
      https://forum.qt.io/topic/24530/solved-shortening-a-label/3
      you can just promote your widgets to ElideLabel
      http://doc.qt.io/qt-5/designer-using-custom-widgets.html
      make it easy to switch them out.

      1 Reply Last reply
      3

      • Login

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