QWidget in layout, geometry() not updated on resize
-
Hi
If i read geometry of widget in a layout its not reflecting its actual size.
How can i get the actual x,y and width and height.
From layout? -
Hi,
When and how are you reading it ?
-
@SGaist
Hi
After they are shown,
First without layout, and draw the rects.
Then apply layout in designer and run and replot.Effect can also be seen directly in Designer
The geometry is frozen in values as soon as you add layout -
Do you have a small sample to reproduce that ?
-
@SGaist
Let me try make one.
and then after applying layout in DesignerThe code runs when Calc is pressed. So they are always visible.
with layout.I do the same in both cases:
QList<QWidget*> widgets = parent->findChildren<QWidget*>(); foreach(QWidget* widget, widgets) { qDebug() << widget->metaObject()->className() << "" << widget->isHidden(); if (widget->isHidden()) continue; InfoShape s; QRect r = rect();// drawing area s.box = widget->geometry(); // actual widget
I first though the layout was not complete ( delayed) but it cant be case when triggering with button.
-
I do map coordinates to parent. It hits me that maybe layout would affect that.
-
Yep, sorry. geometry is updated, its was due to incorrect mapping from local/global when layout is involved.
-
Glad you found out and thanks for sharing your findings :)