Eddie
Eddie

Reputation: 1643

QScrollArea widget auto resize when adding child widgets

I have the following structure:

QScrollArea
  - QWidget (with QHBoxLayout)
    - QLabel
    - QLabel
    - QLabel
    ...

QLabels are generated automatically with random text.

How do I change the size of the widget automatically to fit labels?

At the moment, I can see the widget only by setting a fixed size.

Upvotes: 0

Views: 2434

Answers (1)

shofee
shofee

Reputation: 2129

Use resize() method on the widget.

resize(sizeHint()) 

Upvotes: 1

Related Questions