import QtQuick 2.11 import QtQuick.Controls 2.14 Item { id:root property int hideWith Loader{ id:loader anchors.fill: parent } function show(text){ loader.sourceComponent = undefined loader.sourceComponent = component loader.item.show() loader.item.text = text } function exit(){ loader.sourceComponent = undefined } Component{ id:component Item { id:item property alias text:fgtext.text function show(){ animationShow.running = true } //加载任务动画效果 NumberAnimation { id: animationShow target: item property: "x" from: root.hideWith to: 0 duration: 500 } Rectangle{ id:bg anchors.fill: parent color: "black" opacity: 0.5 radius: 4 } Item { id:fg z:bg.z+1 anchors.fill: parent Text { id: fgtext anchors.centerIn: parent color: "white" font.bold: true font.pixelSize: 18 } } } } }