Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Resizing Height and Width of widget while keeping aspect ratio
bearsomg last edited by
I've seen many topics about keeping the aspect ratio of a widget constant when resizing it, but none that seem to cover resizing both the width and height.
So far I overrode the heightForWidth method to return the width scaled by the aspect ratio, and this works as expected. However, this will only work when the window's aspect ratio is smaller than the wanted widge aspect ratio, since it uses width as the calculation. As such, when the width of the window is too wide, the widget will fill up the entire window, presumably increasing in height, when the width should be remaining constant.
Basically, I need the end result of this to be the widget retaining its aspect ratio regardless of whether the aspect ratio of the window is greater or smaller than the wanted aspect ratio. What would be thhe correct way to do this?