How to handle the resize event of mainwindow

hi all, i added a new widget to the top toolbar of the slicer mainwindow, now i wish it have a maximum width equal to the width of the main window, no matter how i resize the mainwindow. what i want to do is handle the resize event of the mainwindow, and set the width of the widget in the event handler, any better ideas to implement this?

Seems like you want to use standard Qt size policy stuff to set the horizontal policy to be expanding.

https://doc.qt.io/qt-5/qsizepolicy.html#Policy-enum

1 Like