[Qt-interest] size of a widget with layout before shown
Karol Krizka
kkrizka at gmail.com
Sun May 31 10:09:01 CEST 2009
On Sat, May 30, 2009 at 8:25 PM, Frank Mertens <frank at cyblogic.de> wrote:
> Frequently I face the same problem with Qt's layout system.
> How to determine the size a widget would take if shown as top-level widget?
> Let's say a QMenu? -- Need to have it placed relative to its size.
>
> I'm used to hack around this issue by show()/hide() and some forced
> manual event processing.
>
> But is there no clean solution?
I'm actually attempting to solve the same problem, so let me know if
you come up with anything clean.
For now, I'm also using a show()/hide() trick. Basically, I start the
widget as hidden. When I want the size, I do the following:
setUpdatesEnabled(false);
widget->show();
widget->hide();
setUpdatesEnabled(true);
When the widget is hidden, I use a spacer to reserve space for it.
--
Cheers,
Karol Krizka
http://www.krizka.net
More information about the Qt-interest-old
mailing list