問題描述和解決方案:
onCutImage: { if(isAdded){ currentModel.insert(currentModel.count, {"imageURL":String(cutImagePrefix + url), "notifyVisible":true}) } else{ currentModel.set(imgIndex, {"imageURL": "", "notifyVisible":true})//1.先把路徑置空 currentModel.set(imgIndex, {"imageURL":String(cutImagePrefix + url), "notifyVisible":true})//2.然后再設置成應該的路徑
} picEdit.close() }
Image{ id:imgItem cache:false//3.把Image的cache屬性設置為false asynchronous:true source: "" sourceSize.width: 30/ratio sourceSize.height:30/ratio smooth: true }
1.因為新版本的Qt的圖片緩存機制,導致相同路徑的圖片只會加載一次。所以要cache = false
2.因為model.set的object是一樣的,可能沒有觸發model數據的刷新,所以要先set(index, {"imageURL" :""})
兩個地方修改之后完美解決~