aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-textarea-scrollable.png (renamed from src/imports/controls/doc/images/qtquickcontrols2-textarea-flickable.png)bin1942 -> 1942 bytes
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-scrollable.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml)13
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp17
3 files changed, 17 insertions, 13 deletions
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-textarea-flickable.png b/src/imports/controls/doc/images/qtquickcontrols2-textarea-scrollable.png
index 39578f71..39578f71 100644
--- a/src/imports/controls/doc/images/qtquickcontrols2-textarea-flickable.png
+++ b/src/imports/controls/doc/images/qtquickcontrols2-textarea-scrollable.png
Binary files differ
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-scrollable.qml
index 6fa64390..aa4d05a8 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-scrollable.qml
@@ -26,25 +26,22 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.1
+import QtQuick.Controls 2.2
Item {
width: 100
height: 100
- Binding { target: flickable.ScrollBar.vertical; property: "active"; value: true }
+ Binding { target: view.ScrollBar.vertical; property: "active"; value: true }
//! [1]
- Flickable {
- id: flickable
+ ScrollView {
+ id: view
anchors.fill: parent
- TextArea.flickable: TextArea {
+ TextArea {
text: "TextArea\n...\n...\n...\n...\n...\n...\n"
- wrapMode: TextArea.Wrap
}
-
- ScrollBar.vertical: ScrollBar { }
}
//! [1]
}
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index fb006c1b..573521cf 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -38,6 +38,7 @@
#include "qquicktextarea_p_p.h"
#include "qquickcontrol_p.h"
#include "qquickcontrol_p_p.h"
+#include "qquickscrollview_p.h"
#include <QtQml/qqmlinfo.h>
#include <QtQuick/private/qquickitem_p.h>
@@ -80,14 +81,13 @@ QT_BEGIN_NAMESPACE
\section2 Scrollable TextArea
If you want to make a TextArea scrollable, for example, when it covers
- an entire application page, attach it to a \l Flickable and combine with a
- \l ScrollBar or \l ScrollIndicator.
+ an entire application page, it can be placed inside a \l ScrollView.
- \image qtquickcontrols2-textarea-flickable.png
+ \image qtquickcontrols2-textarea-scrollable.png
- \snippet qtquickcontrols2-textarea-flickable.qml 1
+ \snippet qtquickcontrols2-textarea-scrollable.qml 1
- A TextArea that is attached to a \l Flickable does the following:
+ A TextArea that is placed inside a \l ScrollView does the following:
\list
\li Sets the content size automatically
@@ -603,6 +603,13 @@ void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem:
d->resolveFont();
if (!d->explicitHoverEnabled)
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(value.item->parentItem());
+ if (flickable) {
+ QQuickScrollView *scrollView = qobject_cast<QQuickScrollView *>(flickable->parentItem());
+ if (scrollView)
+ d->attachFlickable(flickable);
+ }
}
}