i have following repeater:
repeater{ id: raindropid model: 200 delegate: rectangle { x: math.floor(math.random() * windowid.width) y: math.floor(math.random() * windowid.height) property int mlayer: math.floor(math.random() * 4) + 1 property double myspeed: -2.0 * mlayer width:5 height:5 color: "#3399ff" radius: width*0.5 } } and have timer. want modify positions of elements repeater according own properties. how can access raindropid[index] timer?
thanks
use repeater's itemat() method:
import qtquick 2.4 import qtquick.window 2.2 window { id: windowid visible: true width: 400 height: 400 repeater { id: raindropid model: 200 delegate: rectangle { width:5 height:5 color: "#3399ff" radius: width*0.5 } } timer { running: true interval: 1000 repeat: true triggeredonstart: true ontriggered: { (var = 0; < raindropid.count; ++i) { raindropid.itemat(i).x = math.floor(math.random() * windowid.width); raindropid.itemat(i).y = math.floor(math.random() * windowid.height); } } } } you might consider using qt quick particles create rain drops.
Comments
Post a Comment