diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-11 17:53:39 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-12 13:07:53 +0000 |
commit | 17614b700e313648839885ae9814e7f62682be88 (patch) | |
tree | 45e359ed4213d9e81c3d86ef2c23f8fb73e4f571 /src/templates | |
parent | e19a9044fa3cdfa86a4caa11a3e9b619fb7b3c8e (diff) |
SwipeView: warn the user for using anchors
Change-Id: I49b951f8382277ee9ea86f487ee70fe954cf1ece
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates')
-rw-r--r-- | src/templates/qquickswipeview.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/templates/qquickswipeview.cpp b/src/templates/qquickswipeview.cpp index 117e3c20..c33163fe 100644 --- a/src/templates/qquickswipeview.cpp +++ b/src/templates/qquickswipeview.cpp @@ -36,6 +36,7 @@ #include "qquickswipeview_p.h" +#include <QtQml/qqmlinfo.h> #include <QtLabsTemplates/private/qquickcontainer_p_p.h> QT_BEGIN_NAMESPACE @@ -67,6 +68,12 @@ QT_BEGIN_NAMESPACE \l {Container::moveItem()}{move}, and \l {Container::removeItem()}{remove} pages dynamically at run time. + \note SwipeView takes over the geometry management of items added to the + view. Using anchors on the items is not supported, and any \c width + or \c height assignment will be overridden by the view. Notice that + this only applies to the root of the item. Specifying width and height, + or using anchors for its children works as expected. + \labs \sa TabBar, PageIndicator, {Customizing SwipeView}, {Navigation Controls}, {Container Controls} @@ -89,8 +96,16 @@ void QQuickSwipeViewPrivate::resizeItems() const int count = q->count(); for (int i = 0; i < count; ++i) { QQuickItem *item = itemAt(i); - if (item) + if (item) { + QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors; + // TODO: expose QQuickAnchorLine so we can test for other conflicting anchors + if (anchors && (anchors->fill() || anchors->centerIn()) && !item->property("_q_QQuickSwipeView_warned").toBool()) { + qmlInfo(item) << "SwipeView has detected conflicting anchors. Unable to layout the item."; + item->setProperty("_q_QQuickSwipeView_warned", true); + } + item->setSize(QSizeF(contentItem->width(), contentItem->height())); + } } } |