Here's your fish
{
const QSize size
( event
->size
() );
const int height = size.height();
const int width = size.widgth();
if( ratioW * height == ratioH * width ) {
}
else {
parentWidget()->resize( width, (ratioH * width) / ratioW );
}
}
void MyWidget::resizeEvent( QResizeEvent *event )
{
const QSize size( event->size() );
const int height = size.height();
const int width = size.widgth();
if( ratioW * height == ratioH * width ) {
QWidget::resizeEvent( event );
}
else {
parentWidget()->resize( width, (ratioH * width) / ratioW );
}
}
To copy to clipboard, switch view to plain text mode
Although it will probably cease to work if you add a menu, status bar or toolbar to your main window.
Bookmarks