Question

In my project, I have a Group box with a few elements that may need to be hidden, with other elements above and below. If I hide those elements with setHidden(true), the elements are hidden but that leaves a large space in between the other elements.

How would I be able to compact the group box after hiding those elements, so there isn't such a big space?

Was it helpful?

Solution

The reason is not in invalidate(). It's because you have an improper layout on you GroupBox content. if you hide() or show() any QWidget QT automatically invalidates everything up to top-most parent which can be affected by visibility change. So in you case QGroupBox is missing layout, so then you hide element there is nothing to change in regards of QGroupBox geometry, that's why you don't see expected stretching.

OTHER TIPS

Without code, it's a little bit hard to guess, what is missing.

Have you tried QLayout::invalidate() on the layout that is holding your group box after hiding the box?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top