Responsive QWidget: is it possible?



  • Hi,

    I am working on a desktop app composed for several panels. Every panel is a QWidget, but depending on different events, some of the widgets are removed from the interface creating empty spaces. I would like that the remaining widgets automatically expand their dimensions in a responsive way covering the available spaces of the main window.

    Is there a way to implement this requirement? Thanks.


  • Moderators

    Yes: use layouts, like QHBoxLayout, QVBoxLayout, QGridLayout etc. Then all your widgets will automatically adjust their sizes (you can control it by setting size policy).

    I suspect what you describe is an issue that once a QWidget is removed from layout, the layout still keeps it's space (which is now empty). To work around that, use takeAt() when removing widgets.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.