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 ) if ( which != Qt::PreferredSize )
return QSizeF(); return QSizeF();
qreal w = constraint.width(); QSizeF hint;
qreal h = constraint.height();
// better use Minimum Width/Height hints TODO ... // better use Minimum Width/Height hints TODO ...
constexpr qreal aspectRatio = 4.0 / 3.0; 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 else
{ {
w = metric( Panel | QskAspect::MinimumWidth ); hint.rwidth() = metric( Panel | QskAspect::MinimumWidth );
h = metric( Panel | QskAspect::MinimumHeight ); hint.rheight() = metric( Panel | QskAspect::MinimumHeight );
} }
return QSizeF( w, h ); return hint;
} }
void MyToggleButton::updateLayout() void MyToggleButton::updateLayout()