Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ListView automatically update model when scrolling



  • Hello,

    I do have a ListView with multiple component in it. I'm facing an issue.
    The problem is that when I scroll some element out of the visible area the component is updated. Is that normal ? Is there anyway to avoid this behaviour.

    For example I do have a switch. If I change it state and scroll down until it is not visible anymore it states goes back to it previous state by itself.


  • Moderators

    @DavidM29
    I'm afraid that is intended behavior .

    The components get created when they come into view and get destroyed when they disappear.

    And on creation, the default values are loaded.

    If you want the preserve the state of your components, make changing them actually do something.
    E.g. changing the data in the model, changing the underlying c++ backend or store them in inside values in your QML file.



  • @J.Hilk
    Ok thank you. I was afraid that is was not the inteded behaviour. So I'll find a workaround solution. I think I'll store the value in QML variables.


Log in to reply