Search code examples
pythonpyqt5qt-designerqwidget

Dynamic widget placement


I have this configuration where in the middle there's a tableWidget, which is set as centrawidget. I want to make a "filetring" space for my table on the top.

How can I make my tableWidget to move down a little bit on a fileMenu press and make room textbox/label/combobox etc..?

And also after user is down with filtering and searching, a fileMenu button for removing the widgets and make the tableWidget to its original size.

enter image description here


Solution

  • You don't have a table widget as central widget, you only added it to its layout.

    First of all, you need to change the current layout orientation to vertical: right click outside the table and select "Lay out vertically" from the "Lay out" submenu.

    Then, since you need to add a "panel" of widgets, you could use a QWidget as a container: scroll down the widget box until you find "Widget" (it's in the "Container" section), then drop it at the top of the table.
    Finally, start by adding one of the widgets you need for the container panel, right click on an empty area of that panel and set an horizontal layout (similarly to what explained before).

    In this way, you can toggle the visibility of all the widgets in that panel by setting the panel visibility.

    screenshot of the result