I am trying to delete QML object and recreate object like this:
Rectangle{
property var obj
signal videoStopped(variant complete)
function recreate(url){
if(!obj){
console.log("createObject")
obj = videoComponet.createObject(root)
obj.stopped.connect(function(){
videoStopped(obj.status == MediaPlayer.EndOfMedia)
})
}
obj.source = url
obj.play()
}
function stop(){
obj.destroy() // obj.deleteLater()
}
Component{
id: videoComponet
Video {
anchors.fill: parent
visible: true
autoPlay: true; autoLoad: true
}
}
}
C++ side call recreate to generate an object and call stop to delete it.
recreate⇒ console output createObject↓
stop↓
recreate⇒ console no output
Both obj.destroy() and obj.deleteLater() not worked.
How to forcedly delete the dynamically created object just like delete in C++.