View Full Version : Resize widget to layout inside it.

13th January 2012, 23:08
Hi. I'm pretty new in Qt so my question might be stupid, but I can't figure out how to handle my problem.

I have widget with buttons and lineedits inside. Amount of buttons in widget depends on which item is currently selected in QTreeWidget. I added QScrollArea in order to have my widget always in the same size, regardless of how many buttons/lineedits is inside it. But it doesn't work as I want to. I set minimumSize of widget to (200, 150) to see anything. But its too big for 2 buttons and too small for e.g. 20. So I want to resize my widget depending on how many items are in my widget, and I have no idea how to achive that.

PS. Sorry for my English. I'm not a navitve english speaker, and I'm still learning.

14th January 2012, 08:42
Problem solved.

I set setSizeConstraint(QLayout::SetNoConstraint) to layout and everything is as i wanted to:)

14th January 2012, 20:22
I'm not sure this is the right approach. If you post some screenshots or better yet a ui file, maybe we'll suggest a more appropriate solution.