How can I get the width of a QWidget in a QScrollArea to adapt to the width of the scrollarea?
-
The user interface in my case is that the user can add any number of child widgets to a QScrollArea by clicking add and remove buttons in a dialog. The child widgets are all of the same class. I would like these child wildgets to get their preferred size vertically and expand horizontally to fill the scrollarea. Hence I've set the resize policy of the child widgets accordingly. For the QScrollarea I've set the properites for scrollbar to never be present horizontally and when needed vertically. The layout of the QScrollArea is a QVBoxLayout.
The result of these settings is the preferred behavior vertically but horizontally the child widgets gets too large so that they don't fit in the QScollArea. How can I make them expand to fit in the QScrollArea but not more?
-
Hi,
There's one thing to take into account: you should not set a layout on QScrollArea but use the setWidget function in order to place your growing widget in there. On that widget you will set the vertical layout where you insert your custom widgets.
-
This post is deleted!