On 24 May 2024, at 00:52, David M. Cotter <d...@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

Hi David,

QLayout::activate should do what you are looking for. And QLayout::sizeHint 
should give you the size the layout would the window to have. You might be able 
to just call windowP->sizeHint() though.

It might depend on what your various functions do, though. If any of them 
changes any widget’s content in such a way that the widget’s sizeHint would 
change (in which case that widget is supposed to call QWidget::updateGeometry, 
which posts a layout requests event), then you are back in some asynchronous 
situation where the processing of events will result in the layout activating 
again, after you showed the window. Forcing the processing of 
QEvent::LayoutRequest with QCoreApplication::sendPostedEvents before calling 
windowP->show() might help then. Or you can deactivate the layout, or give 
windowP a fixed size based on its sizeHint, when you are confident that future 
changes should be ignored.


Volker

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to