2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2014-02-18 11:15:30 +00:00
|
|
|
|
2022-08-31 07:59:05 +00:00
|
|
|
import QtQuick
|
2014-02-18 11:15:30 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: root
|
2021-11-08 15:16:16 +00:00
|
|
|
property color rectColor: "red"
|
2014-02-18 11:15:30 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property int d: 100
|
|
|
|
id: square
|
|
|
|
width: d
|
|
|
|
height: d
|
|
|
|
anchors.centerIn: parent
|
2021-11-08 15:16:16 +00:00
|
|
|
color: root.rectColor
|
2014-02-18 11:15:30 +00:00
|
|
|
NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; }
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
2021-11-08 15:16:16 +00:00
|
|
|
id: text
|
2014-02-18 11:15:30 +00:00
|
|
|
anchors.centerIn: parent
|
2021-11-08 15:16:16 +00:00
|
|
|
property string api
|
|
|
|
Connections {
|
|
|
|
target: text.GraphicsInfo
|
|
|
|
function onApiChanged() {
|
|
|
|
var api = text.GraphicsInfo.api;
|
|
|
|
if (api === GraphicsInfo.Software)
|
|
|
|
text.api = "Software";
|
|
|
|
else if (api === GraphicsInfo.OpenGL)
|
|
|
|
text.api = "OpenGL on QRhi";
|
|
|
|
else if (api === GraphicsInfo.Direct3D11)
|
|
|
|
text.api = "D3D11 on QRhi";
|
2023-08-28 15:42:34 +00:00
|
|
|
else if (api === GraphicsInfo.Direct3D12)
|
|
|
|
text.api = "D3D12 on QRhi";
|
2021-11-08 15:16:16 +00:00
|
|
|
else if (api === GraphicsInfo.Vulkan)
|
|
|
|
text.api = "Vulkan on QRhi";
|
|
|
|
else if (api === GraphicsInfo.Metal)
|
|
|
|
text.api = "Metal on QRhi";
|
|
|
|
else if (api === GraphicsInfo.Null)
|
|
|
|
text.api = "Null on QRhi";
|
|
|
|
else
|
|
|
|
text.api = "Unknown API";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
text: "Qt Quick running in a widget\nGraphicsInfo.api says: " + api
|
2014-02-18 11:15:30 +00:00
|
|
|
}
|
2016-09-20 10:53:31 +00:00
|
|
|
|
|
|
|
function performLayerBasedGrab(fn) {
|
|
|
|
root.grabToImage(function(result) {
|
|
|
|
result.saveToFile(fn);
|
|
|
|
});
|
|
|
|
}
|
2014-02-18 11:15:30 +00:00
|
|
|
}
|