Small picture to depict what the problem is:
external_widget
+--------------------------------------------------+
| |
| |
| layout_widget |
| +-------------------------------+ |
| | | |
| | [internal_layout] | |
| | | |
| | | |
| | [Some Another Widget] | |
| +-------------------------------+ |
| |
+--------------------------------------------------+
layout_widget
- just QWidget with vertical layout. It contains another internal_layout
and another widgets.
internal_layout
- layout where the widgets will be added and deleted in future.
external_widget
- just QWidget with no layout, I control the position and size of layout widget and other widgets manually.
When I add some widgets in internal_layout
- it sends LayoutRequest event (as far as I know, I saw this in Qt source codes). This event is catched by parent widget and parent widget tells his layout that something is changed which forces layout to recalculate layout_widget
sizeHint() etc.
Do I understand this process right?
The problem is that sizeHint() is changed, but my external_widget
doesn't know anything about that. I want to get notification about layout_widget
sizeHint() changes. Is it possible?
I even tried to do this:
external widget ctor:
{
layout_widget->installEventFilter(this);
}
and tried to catch them:
void ...eventFilter(QObject* obj, QEvent* event )
{
if (obj == layout_widget && event == QEvent::LayoutRequest)
{
// TODO;
}
}
and I never got into "TODO" block.
Do layout_widget
send some events or notifications that something was changed inside him and it should be resized, i.e. his sizeHint() has been changed?