Thanks for your answer.
The heightForwidth provides useful information if you set a QLayout into the QDialog, according to the manual.
int QWidget::heightForWidth ( int w ) const [virtual]
Returns the preferred height for this widget, given the width w.
If this widget has a layout, the default implementation returns the layout's preferred height. if there is no layout, the default implementation returns -1 indicating that the preferred height does not depend on the width.
But it's not my case, I can't add a layout to my QDialog.
If I recalculate the size of the QDialog inside of the resizeEvent, I get a stack overflow errore as I open a loop.
{
[INDENT]qreal ratio = event->size().width()/event->size().height();
if (ratio != heightForWidth(1))
{
event->ignore();
newSize.setWidth(width());
newSize.setHeight(heightForWidth(newSize.width()));
resize(newSize.toSize());
return;
}
QDialog::resizeEvent(event
);
[/INDENT
] }
void myClass::resizeEvent(QResizeEvent * event)
{
[INDENT]qreal ratio = event->size().width()/event->size().height();
QSizeF newSize;
if (ratio != heightForWidth(1))
{
event->ignore();
newSize.setWidth(width());
newSize.setHeight(heightForWidth(newSize.width()));
resize(newSize.toSize());
return;
}
QDialog::resizeEvent(event);[/INDENT]
}
To copy to clipboard, switch view to plain text mode
the command heightForWidth(int width) returns w/=1.6;
How can I do ?
Thanks you.
P.S. should I forget the phi number ?
Bookmarks