aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quicktemplates2/qquickscrollview.cpp12
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml25
2 files changed, 34 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp
index c05e4848..fa9a6c3b 100644
--- a/src/quicktemplates2/qquickscrollview.cpp
+++ b/src/quicktemplates2/qquickscrollview.cpp
@@ -205,7 +205,7 @@ bool QQuickScrollViewPrivate::setFlickable(QQuickFlickable *item, bool content)
void QQuickScrollViewPrivate::updateContentWidth()
{
Q_Q(QQuickScrollView);
- if (!flickable)
+ if (!flickable || !componentComplete)
return;
const qreal cw = flickable->contentWidth();
@@ -219,7 +219,7 @@ void QQuickScrollViewPrivate::updateContentWidth()
void QQuickScrollViewPrivate::updateContentHeight()
{
Q_Q(QQuickScrollView);
- if (!flickable)
+ if (!flickable || !componentComplete)
return;
const qreal ch = flickable->contentHeight();
@@ -551,8 +551,14 @@ void QQuickScrollView::componentComplete()
{
Q_D(QQuickScrollView);
QQuickControl::componentComplete();
- if (!d->contentItem)
+ if (!d->contentItem) {
d->ensureFlickable(true);
+ } else {
+ if (d->contentWidth <= 0)
+ d->updateContentWidth();
+ if (d->contentHeight <= 0)
+ d->updateContentHeight();
+ }
}
void QQuickScrollView::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index c0b1a401..80110b5a 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -129,6 +129,16 @@ TestCase {
}
}
+ Component {
+ id: scrollableTextArea
+ ScrollView {
+ TextArea {
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas id dignissim ipsum. Nam molestie nisl turpis."
+ wrapMode: TextArea.WordWrap
+ }
+ }
+ }
+
function test_scrollBars() {
var control = createTemporaryObject(scrollView, testCase, {width: 200, height: 200})
verify(control)
@@ -339,4 +349,19 @@ TestCase {
}
compare(horizontal.position, 0.0)
}
+
+ function test_textArea() {
+ // TODO: verify no binding loop warnings (QTBUG-62325)
+ var control = createTemporaryObject(scrollableTextArea, testCase)
+ verify(control)
+
+ var flickable = control.contentItem
+ verify(flickable && flickable.hasOwnProperty("contentX"))
+
+ var textArea = flickable.contentItem.children[0]
+ verify(textArea && textArea.hasOwnProperty("text"))
+
+ compare(control.contentWidth, flickable.contentWidth)
+ compare(control.contentHeight, flickable.contentHeight)
+ }
}