Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. GUI freezing despite using incubateObject
Forum Updated to NodeBB v4.3 + New Features

GUI freezing despite using incubateObject

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 156 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alexcrist
    wrote on last edited by alexcrist
    #1

    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 the incubator), 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!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved