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. QLabel won't expand depending on text content
Forum Updated to NodeBB v4.3 + New Features

QLabel won't expand depending on text content

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

    Hi all,

    I am experiencing an issue with a QLabel in a QDialog. I'd like my QLabel to expand depending on the text content.
    This QLabel is in a QHorizontalLayout, itself in a QVerticalLayout.
    Here's how it's designed :

    Designer
    Hierarchy

    I have changed the QLabel's sizePolicy to Expanding.
    I have set the layoutSizeConstraint of all the labels to SetMaximumSize.

    But here's how it's displayed :

    text alternatif

    It still won't expand.

    Anyone would have an idea of what I don't see here ?

    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by m.sue
      #2

      Hi,
      you will have to use FIXED (and not prescribe an actual size) to set the label size according to its contents. Expanding means, every widget with policy EXPANDING gets as much space as allowed by the other widget's policies, maybe more or less than its contents size. If there are two or more widgets with EXPANDING they share the "allowed" space.
      -Michael.

      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