Steve McLenithan
Steve McLenithan

Reputation: 293

Adding a QFrame to a QGridLayout that is inside a QScrollArea breaks scrolling

I'm working on a GUI that requires a scrollable QGridLayout based on the size of the window. My solution was to nest that within a QScrollArea. This works as long as I'm only adding standard widgets to the QGridLayout.

When I switch to adding my widgets to a QFrame and then adding that frame to the gridlayout as before the gridlayout no longer scrolls, instead just squishing all rows of the gridlayout as much as needed to include them all.

Why is this? Is there a fix or a different way to do this? I should mention the only reason I'm using a QFrame is to stylize the background, amongst other things, of the "cell" that is created when adding a widget to a grid layout.

Upvotes: 2

Views: 1766

Answers (1)

Arnold Spence
Arnold Spence

Reputation: 22272

This will happen if your widget is not asserting appropriate minimum sizes via its size hints and size policies.

Upvotes: 1

Related Questions