contentsSizeHint modified

This commit is contained in:
Uwe Rathmann 2019-09-13 06:53:47 +02:00
parent a721b8841d
commit f836967e71
1 changed files with 8 additions and 9 deletions

View File

@ -185,27 +185,26 @@ QSizeF MyToggleButton::contentsSizeHint(
if ( which != Qt::PreferredSize )
return QSizeF();
qreal w = constraint.width();
qreal h = constraint.height();
QSizeF hint;
// better use Minimum Width/Height hints TODO ...
constexpr qreal aspectRatio = 4.0 / 3.0;
if ( w >= 0.0 )
if ( constraint.width() >= 0.0 )
{
h = w / aspectRatio;
hint.rheight() = constraint.width() / aspectRatio;
}
else if ( h >= 0.0 )
else if ( constraint.height() >= 0.0 )
{
w = h * aspectRatio;
hint.rwidth() = constraint.height() * aspectRatio;
}
else
{
w = metric( Panel | QskAspect::MinimumWidth );
h = metric( Panel | QskAspect::MinimumHeight );
hint.rwidth() = metric( Panel | QskAspect::MinimumWidth );
hint.rheight() = metric( Panel | QskAspect::MinimumHeight );
}
return QSizeF( w, h );
return hint;
}
void MyToggleButton::updateLayout()