GithubHelp home page GithubHelp logo

Comments (5)

jebos avatar jebos commented on June 15, 2024 1

yep. true. Well the example is meant to be a bit extreme in that case, so, try to assign color later by simply adding a timer (i.e. with a randomized intervall).

I may adjust the example along this feedback to demonstrate this option.

from qml_fast_scrolling.

jebos avatar jebos commented on June 15, 2024

can you provide some code snipped so I can take a look?

from qml_fast_scrolling.

arunpkqt avatar arunpkqt commented on June 15, 2024

here it is

ListView {
        anchors.fill: parent

        model: 3000

        spacing: 1

        delegate: Item {
            id: delegate

            height: 45
            width: parent.width

            property Item item

            Connections {
                target: item
                ignoreUnknownSignals: true

                onAction: {
                   console.log("blog.basysKom.com: And Action!")
                   item.color = Qt.rgba(Math.random(),Math.random(),Math.random(),1);
                }
            }

            Component.onCompleted: {
                item = elementCache.getDelegate()
                item.parent = delegate
                item.anchors.fill = Qt.binding(function (){ return delegate })
                item.color = Qt.rgba(Math.random(),Math.random(),Math.random(),1);
                item.name = Qt.binding(function (){ return "Current Index:" + index })
                item.aStaticProperty = true
            }

            Component.onDestruction: {
                elementCache.returnDelegate(item)
            }
        }

       ScrollBar.vertical: ScrollBar { }
    }

from qml_fast_scrolling.

jebos avatar jebos commented on June 15, 2024

When taking our example and just adding the ScrollBar {} i don't see any performance degragation. I can scroll with the bar, click around and it just works smooth as expected.

Things that happen when you click on the bar and/or scroll with it:

  • More than 1-2 delegates are pushed back into cache and pulled from it, this will definitly be slower that just swiping around.
  • The bottlenecks can be:
    • not enough precached Items
    • to much time is spend in "onCompleted". To reduce the time you spend in on completed you have to think about moving the loading of data to a later point in time (after the first rendering). The screen/delegate is only rendered after onCompleted.

To look for the bottleneck you:

  1. take a look on the log if you see many new items that are beeing created
  2. comment the steps in onCompleted and check if the situation is improved - if so: load the data later.

from qml_fast_scrolling.

arunpkqt avatar arunpkqt commented on June 15, 2024

Thanks for those hints.

I had a closer look to find the bottleneck with the help of the QML profiler and found that the Component.onCompleted is taking more time to complete.

The actual line where it gets really stuck is the Line :88 where it assigns the color of the Rectangles in the Grid

color:  Qt.rgba(Math.random(), Math.random(), complexDelegate.color * Math.random(), 1);

precisely the third parameter complexDelegate.color * Math.random() which will get re-valuated for all those delegates when the delegate's color get assigned in the Component.onCompleted

from qml_fast_scrolling.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.