GUI freezing despite using incubateObject
Unsolved
QML and Qt Quick
-
Hello,
I'm using QML Shape and ShapePath to draw a basic chart. This works just fine with a few tens or hundreds of items. But my model can sometimes contain more than 10-12.000 items.
The code looks like this:
Shape { property var item anchors.fill: parent asynchronous: true ShapePath { id: path startX: 0 startY: parent.height } onItemChanged: { var elements = []; var currentTrack = item.track; var maxSpeed = item.maxSpeed.value + 10; for (var i = 0; i < currentTrack.length; i++) { var point = currentTrack[i]; var pathLine = Qt.createQmlObject('import QtQuick 2.15; PathLine {}', speedPath); pathLine.x = speedChart.width / (currentTrack.length - 1) * i; pathLine.y = speedChart.height - (speedChart.height / maxSpeed * point.speed.value); elements.push(pathLine); } path.pathElements = elements; } }
The code works fine placed either on the QML page itself, either created using an incubator like so:
var shapeFactory = Qt.createComponent("shape.qml"); chart.data = []; var incubator = shapeFactory.incubateObject(chart, { item: <some_item> }, Qt.Asynchronous); if (incubator.status !== Component.Ready) { incubator.onStatusChanged = function(status) { if (status === Component.Ready) { console.log("done!"); chart.data.push(incubator.object); } } } else { chart.data.push(incubator.object); }
However, both approaches lead to GUI freezes for 12 seconds (without the
incubator
), and 8 seconds (with theincubator
), for a data set of 12.000 points.The slight improvement offered by the incubator doesn't make sense to me. Shouldn't everything be done async? What am I missing or doing wrong about it? :(
Thanks!