Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to combine two or more widgets into different layouts?



  • I have a tab widget containing a row of toolbuttons. However when any of these buttons are clicked I want it to open another widget with fixed parameters at another part on the screen. For example I have a button in the tab that says Collect. If clicked it opens a table widget outside of the tab on another part of the screen that has a set number of rows columns and labels. If I clicked on a different button it still opens a widget in the same place but with a different widget. Is this possible? Are there any reference code to go along with proof it is possible?



  • Hi,
    Use the QStackedWidget for the 'changable' widget. Add the widgets you need to be shown there. Then when a button is clicked set the widget you need on top in the stacked widget.
    There is an example about a configuration setup dialog, but the idea is the same.



  • Thanks!!! I just have one question. Can I link certain widgets in the stack to certain buttons so when there clicked, only the widget corresponding to the button pops up.


Log in to reply