
 Originally Posted by 
cmessineo
					 
				 
				I thought there would be a mechanism for me to hook into when something like this happened:
Timer {
    interval: 10000
    running: true
    onTriggered: if(root.someItem) { root.someItem.destroy(); root.someItem = null }
  }
			
		 
	 
 There are too many situations like that that can cause you trouble. You will not patch and stitch each and every one.
	
		
			
			
				Or even if a QML Item was created through javascript.  Some signal that an object was created or destroyed.
			
		
 
	 
 You can do that using QGraphcisItem API but that will be hell slow since you'd be monitoring every item in the scene. I assure you this is a wrong way to approach your problem. The proper way is to expose some API to QML scripts and ask authors of the scritps to use that API.
E.g. something along the lines of:
	
	- Item { 
-   id: myObject 
-   ChangeListener { 
-     name: "myObject" 
-     properties: [ "width", "height", "x", "y" ]  // listen to changes on these properties 
-     onChanged: myObject[propName] = value // propName and value are parameters of onChanged signal 
-   } 
- } 
        Item {
  id: myObject
  ChangeListener {
    name: "myObject"
    properties: [ "width", "height", "x", "y" ]  // listen to changes on these properties
    onChanged: myObject[propName] = value // propName and value are parameters of onChanged signal
  }
}
To copy to clipboard, switch view to plain text mode 
  
or even:
	
	- Item { 
-   id: myObject 
-   objectName: "myObject" 
-   ChangeListener { 
-     target: myObject 
-     properties: [ "width", "height", "x", "y" ] 
-     // updating the property is done in C++ 
-   } 
- } 
        Item {
  id: myObject
  objectName: "myObject"
  ChangeListener {
    target: myObject
    properties: [ "width", "height", "x", "y" ]
    // updating the property is done in C++
  }
}
To copy to clipboard, switch view to plain text mode 
  
				
			
Bookmarks