javascript - How to connect a destroyed signal of C++ object from QML? -
i want connect destroyed signal of c++ qobject qml did this:
rectangle { id: root width: 128 height: 128 button { anchors.centerin: parent text: "click me" onclicked: { qobj.component.ondestruction.connect(function(){console.log("it destroy")}) // qobj set c++ qobj.destroy() // should output "it destroy" } } but nothing printed when destroy qobj.
in general case, can connect signals emitted c++ object using connections element:
connections { target: yourobjectcomingfromcpp onsomesignal: console.log("something") } or in javascript calling connect function on corresponding property of js-mapped object:
// without *on*! yourobjectcomingfromcpp.somesignal.connect( /* js function here */ ); however: doesn't work specific qobject::destroyed signals, forcibly blacklisted , never available in qml (source).
i guess reason object gone qml context anyhow @ point, plus when signal emitted you're deep qobject's own destructor, means property or method access on subclass invalid @ point.
Comments
Post a Comment