diff options
Diffstat (limited to 'src/quick/doc/snippets/qml/item/itemGrab.qml')
-rw-r--r-- | src/quick/doc/snippets/qml/item/itemGrab.qml | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/quick/doc/snippets/qml/item/itemGrab.qml b/src/quick/doc/snippets/qml/item/itemGrab.qml index ef4430175a..dc5a52a123 100644 --- a/src/quick/doc/snippets/qml/item/itemGrab.qml +++ b/src/quick/doc/snippets/qml/item/itemGrab.qml @@ -1,7 +1,7 @@ // Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.4 +import QtQuick Item { width: 320 @@ -12,12 +12,13 @@ Rectangle { id: sourceRectangle width: 100 height: 100 + focus: true gradient: Gradient { GradientStop { position: 0; color: "steelblue" } GradientStop { position: 1; color: "black" } } - Component.onCompleted: { + Keys.onSpacePressed: { sourceRectangle.grabToImage(function(result) { result.saveToFile("something.png") }) @@ -30,7 +31,7 @@ Image { id: image } -Component.onCompleted: { +Keys.onSpacePressed: { sourceRectangle.grabToImage(function(result) { image.source = result.url }, Qt.size(50, 50)) |