[Qt-interest] Twitching Dialog layout

Colin S. Miller no-spam-thank-you at csmiller.demon.co.uk
Sat Feb 6 15:10:46 CET 2010


David Boddie wrote:
> BRM wrote:
> 
>> I have a layout that has essentially three columns of widgets, with the
>> center column containing text that changes during the run of the program
>> based on events. The text updates on a very regular basis (at least
>> 1/second if not more). This update is causing the layout to occasionally
>> adjust, giving it a heartbeat effect - or twitch. This twitching behavior
>> is undesirable, and it was suggested that I use a fixed-width font.
> 
> You could also set the size policy for those widgets to use something that
> won't cause the layout to change. It might take some experimentation.
David,
two suggestions:

1)
If the controls are in a grid layout, rather than a QVBoxLayout, then
you can call setColumnMinimumWidth() with a value slightly bigger than
the value you think largest width of the second item.

2)
Override sizeHint() on the widget of concern.
The new function will return the width as the
MAX(currWidth, previousWidth)


The latter is guaranteed to work, but the dialog will widen when need,
but not shrink again. This may-or-may not be acceptable to you.

HTH,
Colin S. Miller



More information about the Qt-interest-old mailing list