bitChanger
4th May 2006, 20:46
For this project i'm using Windows and Qt 4.1.2
I have a QMainWindow that contains a widget that occupies the entire window. When the resizeEvent of the child widget is called I want the child to maintain proportions. After fixing the width/height proportions of the child I need to resize the parent.
I've included a complete program that demonstrates the issue.
Here is the wrong solution, but what would be a good workaround for it?
void MyWidget::resizeEvent(QResizeEvent* event)
{
QSize newsz = event->size();
_figureHeight = newsz.width()*_figureHeight/_figureWidth;
_figureWidth = newsz.width();
parentWidget()->resize(_figureWidth, _figureHeight);
}
I have a QMainWindow that contains a widget that occupies the entire window. When the resizeEvent of the child widget is called I want the child to maintain proportions. After fixing the width/height proportions of the child I need to resize the parent.
I've included a complete program that demonstrates the issue.
Here is the wrong solution, but what would be a good workaround for it?
void MyWidget::resizeEvent(QResizeEvent* event)
{
QSize newsz = event->size();
_figureHeight = newsz.width()*_figureHeight/_figureWidth;
_figureWidth = newsz.width();
parentWidget()->resize(_figureWidth, _figureHeight);
}