【QML】同步预览功能实现
日常使用电脑时,当鼠标移到任务栏打开状态下应用的图标上时,会显示预览窗格此处使用QML实现
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Sync Preview")
Rectangle {
id: rect1
x: 30
y: 100
width: 200
height: 200
color: "Green"
MouseArea {
hoverEnabled: true
width: parent.width
height: parent.height
onPressed: parent.color = "Red"
onReleased: parent.color = "Blue"
onEntered: parent.color = "Yellow"
onExited: parent.color = "Green"
}
}
Rectangle {
x: 450
y: 150
width: 100
height: 100
ShaderEffectSource {
width: parent.width
height: parent.height
sourceItem: rect1
}
}
}
页:
[1]