What I'm trying to achieve is that a widget could exist in two different layouts, in this case in QHBoxLayout and in QVBoxLayout. I'm implementing a system which dynamically switches between the two layouts when a device's screen orientation changes.
Currently I'm creating, let's say a complex composite widget called MyWidget and adding it into a two different layouts:
MyWidget *wgt = new QWidget();
QVBoxLayout vlayout;
QHBoxLayout hlayout;
vlayout->addWidget(wgt);
hlayout->addWidget(wgt);
Now imagine that both layouts are hosted within a 'root' layout, and that this root layout can resize into a more wide than tall 'landscape' mode, and into a more tall than wide 'portrait' mode.
The MyWidget shows correctly in only the first layout it is added into, and when the layouts are switched, it shows all wrong or not at all.
I don't know if I'm making any sense here, but this is my problem. Maybe when the switch event is called all child widgets and layouts should be resized, so it would always look right. Only problem is that I don't know how.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With