[Interest] Update widget geometry BEFORE window shown
John Weeks
john at wavemetrics.com
Wed May 29 20:29:39 CEST 2024
Well, I wasn't going to say anything ("If you don’ know how to answer it, please don’t chime in, thanks.")
In my experience, Qt doesn't maintain a good notion of a window's size until it's shown. But you are guaranteed a Resize event as the window is being shown, so if you can manage it, you need to handle the Resize event and do your polishing and layouting there.
In fact, I had for a while a function called ShowAndHideInvisibly(); the important part of it was like this:
> getQWidget()->setAttribute(Qt::WA_DontShowOnScreen, true);
> WMshow();
> WMhide();
> getQWidget()->setAttribute(Qt::WA_DontShowOnScreen, false);
Maybe that helps. Setting the attribute prevents the screen flash.
-John Weeks
WaveMetrics, Inc.
> On May 23, 2024, at 3:52 PM, David M. Cotter <dave at kjams.com> wrote:
>
> I need to do something like this:
>
> windowP->layout()->updateGeometry(); // causes all widget geometry to update
> DoSomethingImportant(windowP->GetWidget(“someWidget”).geometry()); // do something with the geometry of a widget (which must be up to date)
> windowP->setGeometry(windowP->GetInitialGeometry()); // pos/size now based on the fact that we KNOW the geometry of one of the widgets BEFORE the window is shown
> windowP->show(); // only NOW show the window, NOT before now
>
> How do I do something like the first line? Cause all widget geometry (Recursively), to know / figure out its size AND position? And this BEFORE the window or any widget is “shown” via the windowP->show() command?
>
> Please don’t try to tell me to do it differently. If you don’ know how to answer it, please don’t chime in, thanks.
>
> -Dave
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list