Qt – How to dynamically hide/show widgets

layoutqtuser-interface

I want to dynamically hide/show widget like so:

Default:
|-------|
|       |
| text  |
| editor|
|-------|


With webkit preview:
|-------|-------|
|       |       |
| text  | web   |
| editor| widget|
|-------|-------|


With okular preview:
|-------|-------|
|       |       |
| text  | okular|
| editor| widget|
|-------|-------|

Best Solution

Just add all your widgets into the layout and use QWidget::hide(), QWidget::show() when needed.

For more complex situations you can use The State Machine Framework.

Related Question