3

Suppose I have a QLabel and want to change its text. If text is too long to be show entirely, I loose a part of it. Can I re-dimension the QLabel according to the text I write in it?

ymoreau
  • 3,402
  • 1
  • 22
  • 60
LittleSaints
  • 391
  • 1
  • 6
  • 19

1 Answers1

1

If you put your label into a layout its size will change to fit the text it contains (in the limits of the available space given by the layout).

By default QLabel has a horizontal-sizePolicy of QSizePolicy::Preferred which makes it to resize just enough to display its content (or expand if there is empty space around that no other widget use, or reduce if others widgets are requiring too much space).

ymoreau
  • 3,402
  • 1
  • 22
  • 60