diff options
author | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2012-09-03 06:35:39 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-21 23:17:55 +0200 |
commit | 42d681f9cfc984046a93b9efe19903d46ac68bb1 (patch) | |
tree | 0a93a177458dc661b9ceb200f8fa21250b6b601f /src/widgets/kernel/qboxlayout.cpp | |
parent | e327ba191df56f3315a004d7650d5f1080f12acb (diff) |
Add widget replace function to QLayout
Sometimes it is nice to be able to replace a widget in a layout.
Change-Id: I23a6a65e417e94d53bc48639503db1a142bc3f10
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/widgets/kernel/qboxlayout.cpp')
-rw-r--r-- | src/widgets/kernel/qboxlayout.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index d0e7a16999..67621ade23 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -140,6 +140,7 @@ public: void calcHfw(int); void effectiveMargins(int *left, int *top, int *right, int *bottom) const; + QLayoutItem* replaceAt(int index, QLayoutItem*) Q_DECL_OVERRIDE; }; QBoxLayoutPrivate::~QBoxLayoutPrivate() @@ -444,6 +445,21 @@ void QBoxLayoutPrivate::calcHfw(int w) hfwMinHeight = mh; } +QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item) +{ + Q_Q(QBoxLayout); + if (!item) + return 0; + QBoxLayoutItem *b = list.value(index); + if (!b) + return 0; + QLayoutItem *r = b->item; + + b->item = item; + q->invalidate(); + return r; +} + /*! \class QBoxLayout |