RT
首先是一个Rect,我需要把这个作为一个组件在别的
文件里使用
- //ChangeImg.qml
- Rectangle {
-     width : 100;
-     height : 100
-     Image{
-         id:imgx
-         source : "A1.png"
-         anchors.fill : parent
-     }
- }
然后是使用这个组件
- //mian.qml
- Column{
-     ChangeImg{
-         id:a1
-         width : 100 
-         height : 100
-     }
-     ChangeImg{
-         id:a2
-         width : 100 
-         height : 100
-     }
-     Component.onCompleted : {
-         //a2.Image.source = "A2.png";   #语句1
-         //ChangeImg.imgx.source = "A2.png";   #语句2
-         //a1.imgx.source = "know.png";   #语句3
-     }
- }
现在因为某些需求,需要在Column中修改Rect中的
图片,
语句1 :无效
语句2 :
QML提示"file:///D:/QML/TestImg/main.qml:16: TypeError: Value is undefined and could 
not be converted to an object"
语句3 : 结果同语句2
所以,如何在这个Column中修改Rect的图片?