Please nominate your Qt Champions for 2021!

How to force layouts to recompute under Qt 3

  • Folks,

    I wonder if someone could help me with the following question. I have an application with a large GUI, with many separate pages filled with widgets that are combined into a hierarchy of QTabWidgets. For efficiency reason, I would like to postpone constructing some of the widgets just before a user opens a relevant page. Right now I create them just before the show() call in an overloaded show() function. With Qt4 it works just fine (the window size adjusts automatically to accommodate newly created widgets), but with Qt3 the layouts for the whole application are not being redone - if the new widget does not fit on the existing window space, it gets cut off rather than for the whole application window to expand to maintain the proper layouts. I would like to maintain Qt3 compatibility for a while, since it is still used widely on Linux.

    I wonder if anyone knows how to force layouts under Qt3 to recompute? I tried many things with no avail, including calling invalidate() and activate() on all layouts in the application.

    Many thanks for any advice.

  • If I remember correctly, something of a combination of calling update() or adjustSize() on the widget and/or calling invalidate() on the toplevel layout of the widget triggers a recalculation of the needed size.

Log in to reply