Forcing an Aspect Ratio when resizing a main window frame



  • I understand that in Qt4, there is no single flag you can set to have the mouse driven resizing of the window maintain a certain aspect ratio (say, 1:1). Is there a way to force a new size for the window while in "resizeEvent (QResizeEvent * event)"? the parameters of the event don't seem to support change or give the user a chance to inject a new size.

    My goal: GUI/Mouse resizing of a certain window frane will maintain its current aspect ratio, regardless of where you resize it from (sides, top, bottom, corners).



  • You should be able to use QSizePolicy::setHeightForWidth(true) + override QWidget::heightForWidth().



  • Did it. my main window frame still re-sizes the same way, my virtual "heightForWidth()" isn't even called.



  • How are you doing it? And which OS/WM are you using? (Now that I reread those methods docs, they mention the equivalent counterparts in QLayoutItem... perhaps it's something good to investigate).


Log in to reply
 

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