diff --git a/src/layouts/QskGridBox.cpp b/src/layouts/QskGridBox.cpp index c357a378..82e44821 100644 --- a/src/layouts/QskGridBox.cpp +++ b/src/layouts/QskGridBox.cpp @@ -438,14 +438,26 @@ QSizeF QskGridBox::contentsSizeHint() const qreal QskGridBox::heightForWidth( qreal width ) const { + const auto m = margins(); + width -= m.left() + m.right(); + const QSizeF constraint( width, -1 ); - return engine().sizeHint( Qt::PreferredSize, constraint ).height(); + qreal height = engine().sizeHint( Qt::PreferredSize, constraint ).height(); + + height += m.top() + m.bottom(); + return height; } qreal QskGridBox::widthForHeight( qreal height ) const { + const auto m = margins(); + height -= m.top() + m.bottom(); + const QSizeF constraint( -1, height ); - return engine().sizeHint( Qt::PreferredSize, constraint ).width(); + qreal width = engine().sizeHint( Qt::PreferredSize, constraint ).width(); + + width += m.left() + m.right(); + return width; } void QskGridBox::setRowSizeHint( diff --git a/src/layouts/QskLinearBox.cpp b/src/layouts/QskLinearBox.cpp index 74aa7db0..203fa2d2 100644 --- a/src/layouts/QskLinearBox.cpp +++ b/src/layouts/QskLinearBox.cpp @@ -333,14 +333,26 @@ QSizeF QskLinearBox::contentsSizeHint() const qreal QskLinearBox::heightForWidth( qreal width ) const { + const auto m = margins(); + width -= m.left() + m.right(); + const QSizeF constraint( width, -1 ); - return engine().sizeHint( Qt::PreferredSize, constraint ).height(); + qreal height = engine().sizeHint( Qt::PreferredSize, constraint ).height(); + + height += m.top() + m.bottom(); + return height; } qreal QskLinearBox::widthForHeight( qreal height ) const { + const auto m = margins(); + height -= m.top() + m.bottom(); + const QSizeF constraint( -1, height ); - return engine().sizeHint( Qt::PreferredSize, constraint ).width(); + qreal width = engine().sizeHint( Qt::PreferredSize, constraint ).width(); + + width += m.left() + m.right(); + return width; } void QskLinearBox::setupLayoutItem( QskLayoutItem* layoutItem, int index ) diff --git a/src/layouts/QskStackBox.cpp b/src/layouts/QskStackBox.cpp index 246b033f..06790a49 100644 --- a/src/layouts/QskStackBox.cpp +++ b/src/layouts/QskStackBox.cpp @@ -240,6 +240,9 @@ QSizeF QskStackBox::contentsSizeHint() const qreal QskStackBox::heightForWidth( qreal width ) const { + const auto m = margins(); + width -= m.left() + m.right(); + qreal height = -1; const QskLayoutEngine& engine = this->engine(); @@ -250,11 +253,15 @@ qreal QskStackBox::heightForWidth( qreal width ) const height = qMax( height, QskLayoutConstraint::heightForWidth( item, width ) ); } + height += m.top() + m.bottom(); return height; } qreal QskStackBox::widthForHeight( qreal height ) const { + const auto m = margins(); + height -= m.top() + m.bottom(); + qreal width = -1; const QskLayoutEngine& engine = this->engine(); @@ -265,6 +272,7 @@ qreal QskStackBox::widthForHeight( qreal height ) const width = qMax( width, QskLayoutConstraint::widthForHeight( item, height ) ); } + width += m.left() + m.right(); return width; }