[Solved] Why children widgets overlapping in QGridLayout?
-
I have an widget x with fixed size. Then at first I took a QScrollArea and then a QGridLayout which I set as the layout of scrollAreaWidgetContent. Then I started adding some widget x in the layout at (0,0), (0,1), (1,0), (1,1)... of grid layout. Then when I ran the program, strangely when I shrink the window vertically, the widgets overlap.
!http://imgur.com/gMMF5mK.png(Overlapped Widgets)!
And as expected, when I increase the window size vertically, they are not overlapped anymore.
!http://i.imgur.com/yGmty8a.png(Non Overlapped when stretched)!
But strange thing is this problem does not occurring when I shrink window horizontally. For example,
!http://imgur.com/6nxmotz.png(Horizontal shrinking)!
My question is, why this is happening and more importantly, keeping in mind I want to use gridlayout, how to solve this problem?
Edit: I am using Qt Creator 3.1.1 based on Qt 5.2.1
-
Hi and welcome to devnet,
You should also add which version of Qt you are using
-
[quote author="SGaist" date="1405028510"]Hi and welcome to devnet,
You should also add which version of Qt you are using[/quote]
Hi and thanks. I am using Qt Creator 3.1.1 based on Qt 5.2.1
-
Did you set the sizePolicy of your widget with QSizePolicy::MinimumExpanding for vertical ?
-
Nope, but I solved the problem anyway. I don't know why it solved the problem. The scrollbar had a minimum height set. I set it back to 0, recompiled and run, and the problem was gone!
-
Nice you found a solution and thanks for sharing.
Please update the thread title prepending [solved] so other forum users may know a solution has been found :)