diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2009-08-31 16:15:13 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2009-08-31 16:20:51 (GMT) |
commit | 758f4735bcae034ac25730e53bb371df3b7d6e8a (patch) | |
tree | 7086950b36e5b46ab5a034839c1e489904e51fc1 /src/gui/kernel/qwidget.cpp | |
parent | e70980b2aacbc758a0cd1e2246633278f7c505ab (diff) | |
download | Qt-758f4735bcae034ac25730e53bb371df3b7d6e8a.zip Qt-758f4735bcae034ac25730e53bb371df3b7d6e8a.tar.gz Qt-758f4735bcae034ac25730e53bb371df3b7d6e8a.tar.bz2 |
Make QMargins a proper class
Since we need QMargins for other things then
the CSS helper functions in drawutil, we have to make it more
generic. It is already useful for QWidget::contentsMargins
for example. This ensures we have some flexibility on how to
use and modify it in the future.
Reviewed-by: mbm
Diffstat (limited to 'src/gui/kernel/qwidget.cpp')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ff644b8..37ffa8fb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6748,7 +6748,27 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom) QApplication::sendEvent(this, &e); } -/*! Returns the widget's contents margins for \a left, \a top, \a +/*! + \overload + \since 4.6 + + Sets the margins around the contents of the widget to have the + sizes determined by \a margins. The margins are + used by the layout system, and may be used by subclasses to + specify the area to draw in (e.g. excluding the frame). + + Changing the margins will trigger a resizeEvent(). + + \sa contentsRect(), getContentsMargins() +*/ +void QWidget::setContentsMargins(const QMargins &margins) +{ + setContentsMargins(margins.left(), margins.top(), + margins.right(), margins.bottom()); +} + +/*! + Returns the widget's contents margins for \a left, \a top, \a right, and \a bottom. \sa setContentsMargins(), contentsRect() @@ -6767,6 +6787,20 @@ void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) c } /*! + \since 4.6 + + Returns the widget's contents margins. + + \sa getContentsMargins(), setContentsMargins(), contentsRect() + */ +QMargins QWidget::contentsMargins() const +{ + Q_D(const QWidget); + return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); +} + + +/*! Returns the area inside the widget's margins. \sa setContentsMargins(), getContentsMargins() |