[Interest] Update widget geometry BEFORE window shown

David M. Cotter dave at kjams.com
Wed May 29 01:32:13 CEST 2024


Tried that too, to no avail

static void activateLayoutsRecursive(QObject *objectP)
{
	if (objectP) {

		for (auto* childP: objectP->children()) {
			activateLayoutsRecursive(childP);
		}

		QWidget*		widgetP(dynamic_cast<QWidget*>(objectP));

		if (widgetP) {
			widgetP->updateGeometry();

			QLayout*	layoutP(widgetP->layout());

			if (layoutP) {
				layoutP->invalidate();
				layoutP->update();
				layoutP->activate();
			}
		}
	}
}


> On May 27, 2024, at 1:07 AM, Tony Rietwyk <tony at rightsoft.com.au> wrote:
> 
> Hi Dave,
> 
> I have had a similar issue at various times, especially in Qt4, but not as much in Qt5 & 6.  A few places still had problems when adjusting after creating or deleting widgets, or switching pages in an embedded page control.  This is the routine I use:
> 
> void activateLayoutsRecursive(QWidget *w)
> {
>     if (w)
>     {
>         // Depth first traversal. 
>         for (auto k : w->children())
>         {
>             if (auto z = qobject_cast<QWidget *>(k))
>                 activateLayoutsRecursive( z );
>         }
> 
>         if (w->layout())
>         {
>             w->layout()->invalidate();
>             w->layout()->activate();
>             //qCDebug(lc) << w->objectName() << w->layout()->totalMinimumSize();
>         }
>     }
> }
> 
> I hope that helps!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240528/e455cc8e/attachment.htm>


More information about the Interest mailing list