blob: dc5a52a1232286ddb2c6744f1a0a6beef93968df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
Item {
width: 320
height: 480
//! [grab-to-file]
Rectangle {
id: sourceRectangle
width: 100
height: 100
focus: true
gradient: Gradient {
GradientStop { position: 0; color: "steelblue" }
GradientStop { position: 1; color: "black" }
}
Keys.onSpacePressed: {
sourceRectangle.grabToImage(function(result) {
result.saveToFile("something.png")
})
}
}
//! [grab-to-file]
//! [grab-to-image]
Image {
id: image
}
Keys.onSpacePressed: {
sourceRectangle.grabToImage(function(result) {
image.source = result.url
}, Qt.size(50, 50))
}
//! [grab-to-image]
}
|