diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-07-29 12:33:25 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-07-30 15:13:31 (GMT) |
commit | 6a2621b6832dbdd349f77cf1f3242b4a6ba3c740 (patch) | |
tree | e49fcef6cfd75a5dca0d2b898f234c11339fe63e /src/gui | |
parent | 705a4811e3bdfddc4dbfe1499fe311c1fa3c5b38 (diff) | |
download | Qt-6a2621b6832dbdd349f77cf1f3242b4a6ba3c740.zip Qt-6a2621b6832dbdd349f77cf1f3242b4a6ba3c740.tar.gz Qt-6a2621b6832dbdd349f77cf1f3242b4a6ba3c740.tar.bz2 |
Added an ability to remove size constraints from a widget.
QWidget::setFixedSize() constrains the size of the widget, however there
was no way to remove those constraints, so setting the constraints to
QWIDGETSIZE_MAX will make the widget resizable again.
Reviewed-by: Leonardo Sobral Cunha
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index bca607c..8b8a853 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3491,11 +3491,16 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) minh = qMax(minh, 0); } createExtra(); - if (extra->minw == minw && extra->minh == minh) + int mw = minw, mh = minh; + if (mw == QWIDGETSIZE_MAX) + mw = 0; + if (mh == QWIDGETSIZE_MAX) + mh = 0; + if (extra->minw == mw && extra->minh == mh) return false; - extra->minw = minw; - extra->minh = minh; - extra->explicitMinSize = (minw ? Qt::Horizontal : 0) | (minh ? Qt::Vertical : 0); + extra->minw = mw; + extra->minh = mh; + extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0); return true; } @@ -3555,7 +3560,8 @@ bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) return false; extra->maxw = maxw; extra->maxh = maxh; - extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); + extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | + (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); return true; } @@ -3634,6 +3640,8 @@ void QWidget::setBaseSize(int basew, int baseh) This will override the default size constraints set by QLayout. + To remove constraints, set the size to QWIDGETSIZE_MAX. + Alternatively, if you want the widget to have a fixed size based on its contents, you can call QLayout::setSizeConstraint(QLayout::SetFixedSize); @@ -3675,7 +3683,8 @@ void QWidget::setFixedSize(int w, int h) else d->updateGeometry_helper(true); - resize(w, h); + if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX) + resize(w, h); } void QWidget::setMinimumWidth(int w) |