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. How to emit dataChanged to a single role of QAbstractListModel?

How to emit dataChanged to a single role of QAbstractListModel?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 3.1k Views
  • 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.
  • T Offline
    T Offline
    themts
    wrote on last edited by
    #1

    Hi guys,

    I have a massive performance problem with a ListView.
    I'm using a subClass of QAbstractListModel as a model for some Data.
    In my listView I have a delegate with 14 bindings where 3 values are always visible, and the rest is hidden in a detail-area which you can expend (visible = false when not expended).

    There is only one of these 14 values which can actually change all the time, but unfortunately I can only fire a dataChanged-signal for the complete model-element.
    The performance is terrible! The Analyze-Tool shows me that all elements gets updated, even the hidden ones.

    How can I solve this problem? I have the feeling that QAbstractListModel is not suitable for this purpose but on the other hand it's the recommended way of propagating model-data.

    CU
    mts

    P.S. Qt 5.5

    1 Reply Last reply
    0
    • T Offline
      T Offline
      themts
      wrote on last edited by
      #2

      I just made a trial and used a QList<QObject*> as a model. -> no Problems at all.
      I think its a major problem of QAbstractListModel that you cannot emit which data has to be updated!

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Without seeing your code, it's pretty difficult to say if it's a limitation of QAbstractListModel or if there's something not optimal with your setup.

        Can you show how you implemented your model ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Paul ColbyP Offline
          Paul ColbyP Offline
          Paul Colby
          wrote on last edited by
          #4

          @themts said:

          but unfortunately I can only fire a dataChanged-signal for the complete model-element.

          If I understand correctly, it sounds like you want to be using the third parameter (roles) of the dataChanged signal. It defaults to an empty vector which "means that all roles should be considered modified".

          1 Reply Last reply
          0
          • T Offline
            T Offline
            themts
            wrote on last edited by
            #5

            @themts said:

            he performance is terr

            I already use the third parameter of dataChanged.
            I'm using a modified version of Thomas Boutroue's QQmlObjectListModel.
            emit dataChanged(index, index, rolesList);
            where roleList has only one item (with the modified role), when I check the Analyze-Tool, I can see that every Binding gets called.
            Screenshot QAbstractListModel
            Screenshot QList

            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