[Interest] managing (deleting) dynamically created QML objects: Property 'destroy' of object TypeError: Type error is not a function

Jason H jhihn at gmx.com
Fri Jul 24 16:22:43 CEST 2015


So I successfully create them, but have trouble deleting them. 
Rectangle {
	property var indicators: []
	function updateIndicators() {
		var i;
		var indicator;

		var component = Qt.createComponent("LastLocationIndicator.qml");
		var last;
		for (i=0; i< control.last.length; i++)
		{
			last = control.last[i];
			indicator = component.createObject(control, {model: control.source, dotColor: App.colors.orange, centerX: last.x,  centerY: last.y});
			indicator.clicked.connect(indicatorClicked);
			indicators.push(indicator);
		}
		
		console.log("ADD INDICATORS:",source, indicators.length)
	}
----------------
But then to delete:
	function clearIndicators() {
		console.log("CLEAR INDICATORS:",source, indicators.length)
		for (var i=0; i< indicators.length; i++)
		{
			var indicator = indicators[i];
			indicator.destroy();
			//delete indicators[i];
		}
	}

--------------
However on the indicator.destroy() line I get:
TypeError: Property 'destroy' of object TypeError: Type error is not a function

What am I doing wrong?



More information about the Interest mailing list