[Interest] Update widget geometry BEFORE window shown
Tony Rietwyk
tony at rightsoft.com.au
Mon May 27 10:07:09 CEST 2024
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!
Tony
On 27/05/2024 4:01 pm, David M. Cotter wrote:
> Does ANY ONE have any ideas on this?? Pretty please??
>
> -dave
>
>> On May 24, 2024, at 12:14 PM, David M. Cotter <dave at kjams.com> wrote:
>>
>> I’ve tried everything I can think of. The ONLY one that works the way
>> I NEED is the first one, but that one flashes the window on the screen
>>
>> #if 1
>> qWidgetP->show();
>> qWidgetP->hide();
>> QtLetTimersFire(0);
>> #endif
>>
>> #if 0
>> QLayout*layoutP(qWidgetP->layout());
>>
>> layoutP->update();
>> layoutP->activate();
>> QtLetTimersFire(0);
>> #endif
>>
>> #if 0
>> for (auto* childP: qWidgetP->findChildren<QWidget*>()) {
>> childP->updateGeometry();
>> }
>>
>> qWidgetP->updateGeometry();
>> QtLetTimersFire(0);
>> #endif
>>
>> #if 0
>> qWidgetP->setAttribute(Qt::WA_DontShowOnScreen, true);
>> qWidgetP->show();
>> // qWidgetP->layout()->invalidate();
>> // qWidgetP->layout()->update();
>> // qWidgetP->layout()->activate();
>> qWidgetP->hide();
>> qWidgetP->setAttribute(Qt::WA_DontShowOnScreen, false);
>> QtLetTimersFire(0);
>> #endif
>>
>> #if 0
>> qWidgetP->setAttribute(Qt::WA_DontShowOnScreen, true);
>> qWidgetP->show();
>>
>> qWidgetP->layout()->invalidate();
>> qWidgetP->layout()->update();
>> qWidgetP->layout()->activate();
>>
>> for (auto* childP: qWidgetP->findChildren<QWidget*>()) {
>> childP->updateGeometry();
>> }
>>
>> qWidgetP->updateGeometry();
>>
>> qWidgetP->hide();
>> qWidgetP->setAttribute(Qt::WA_DontShowOnScreen, false);
>> QtLetTimersFire(0);
>> #endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240527/ed7519ed/attachment-0001.htm>
More information about the Interest
mailing list