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

Put 2 widgets on top of each other



  • Hello I wonder if it is possible to put 2 widgets such as QTableWidget to top of eachother. I want to have 2 TableWidgets and when a button pressed, I want to show other widget and hiding the previous one. For example, button pressed -> Hide first table show second, another button press->show first table and hide the second one. I tried that from the UI but it did not let me put 2 tablewidgets on top of each other. I was thinking putting widget outside of the window then when button pressed, moving the widget to the desired position. But layout does not let me move the widgets by code. Is there a trick I can achieve to have 2 QTableWidgets on each other while one is visible and other one is invisible.



  • You can't if you put them into layouts in the designer.
    Why don't you use QStackedWidget for that?



  • You can't if you put them into layouts in the designer.
    Why don't you use QStackedWidget for that?



  • I did not know something like that exists ^^. I checked that out and it looks like, the widget I choose from the index gets shown in the window. So simply I will put a QStackedWidget in the place of my QTableWidget and then put 2 QTableWidgets in it I believe.


Log in to reply