【QML学习】Component与Loader
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Loader{
id: loader
sourceComponent: com
//width: 50
//height: 50
}
Component{
id: com
AnimatedImage{
id: animg
source: "/resouce/test.gif"//路径
speed: 2
}
}
Button{
id: btn
width: 50
height: 50
x: 200
onClicked: {
loader.item.width = 100
loader.item.height = 100
}
}
}

浙公网安备 33010602011771号