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 with layouts: sizes
Forum Updated to NodeBB v4.3 + New Features

QLabel with layouts: sizes

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

    Hi, all!

    I want to fit sizes of my QLabel in layout according to its text.
    @
    label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    label->setWordWrap(true);
    label->setOpenExternalLinks(true);
    @

    Then I add it to layout. But how to make it fittable to its sizes? I want it to be bigger when there are more text and smaller when there are less text.

    Actually, it displays on the center+left of the layout. But how to make it smaller?

    !http://habrastorage.org/storage2/22e/1ac/51c/22e1ac51cbe980b7c229b43593f7b4ec.png(abbr)!

    How to deal with it?

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      QMartin
      wrote on last edited by
      #2

      Hello tucnak!

      Whenever you set the label's text or introduce something in it, call

      @label->adjustSize();@

      after your code. This action should resize your label if your content does not fit or it is smaller than before. Hope this helps!

      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