From 77220db5d2ef2eee22f8456527f2ae66ea457685 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 4 Jul 2015 21:11:24 +0200 Subject: Scroll to active item when list is expanded List expansion only happens when a new item is added and as such the `onHeightChanged` signal allows for bringing the new item into view. This work around is necessary as all my attempts to scroll with the output by e.g. using the `onExecuted` signal of `TerminalItem` failed. Reasons for this include both the async nature of JavaScript which makes it inconvenient to enforce execution of a function at exactly the right time, as well as the height value of `terminalList` seemingly not being updated instantly. --- MetaTerm.qml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MetaTerm.qml') diff --git a/MetaTerm.qml b/MetaTerm.qml index 0b2046a..9ee41a3 100644 --- a/MetaTerm.qml +++ b/MetaTerm.qml @@ -18,6 +18,7 @@ Rectangle { boundsBehavior: Flickable.StopAtBounds contentHeight: terminalList.height contentWidth: terminalList.width + pixelAligned: true Column { id: terminalList @@ -25,6 +26,8 @@ Rectangle { property int activeItem : 0 + onHeightChanged: scrollTo(activeItem) + function createItem() { var terminalItem = Qt.createComponent("TerminalItem.qml"); var instantiateTerminal = function() { -- cgit v1.2.3