开发者

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

开发者 https://www.devze.com 2023-03-24 21:48 出处:网络
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

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 backgroun开发者_如何学编程d, amongst other things, of the "cell" that is created when adding a widget to a grid layout.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号