0
votes

I am using Qlabels to plot some graphs and images (via setpixmap).

My basic layout is:

QVBoxlayout main layout via qdialog's setlayout. QHboxlayout (array of QLabels) Qlabel expandedPlot (optional expanded plot of one of the above QLabels) QLabel mainImage Main image display

Within the QDialogs re-implemented keypress event handler, I hide()/show() the expanded plot. When I hide() the expandedPlot, the layoutmanager recovers about 1/2 of the vertical usage. Then when I drag the window, the layout manager recovers the remainder of the vertical space (as if there was no item present).

How can I force the behavior of moving the window? I want the layout manager to completely recover the vertical space.

I am using Qt 5.6 on windows, but want cross-platform solutions. Thank you, mike

1
Do you call updateGeometry on the hidden widget? A cut-down version of your code showing the problem would improve this question.strubbly
No - looks like updateGeometry is a no-op in this case. Try adjustSize on the parent.strubbly
Hi Strubbly, Thank you. That worked perfectly.mike ingle

1 Answers

0
votes

Because laying out the widget is quite expensive, Qt doesn't always do it. If you change the size of enclosed widgets you are likely to need to call updateGeometry on them to trigger the enclosed layout manager to re-layout. But if you hide the widget, updateGeometry does nothing. In that case you need to call adjustSize on the parent widget, which will then trigger the re-layout.