Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QListView does not update when underlying data changes
Forum Updated to NodeBB v4.3 + New Features

QListView does not update when underlying data changes

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 3.5k 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.
  • T Offline
    T Offline
    thEClaw
    wrote on last edited by
    #1

    I am working on a custom view (currently QListView) that is supposed to use icons instead of text.
    The icons are loaded in another thread, the items in the view shall be updated accordingly (and asynchronously).
    BUT: The icons don't show up, the view isn't updated, the delegates paint()-function is only called once when I launch the program and rarely (and seemingly randomly) after that.

    As far as I know, changing the contents (i.e. the text) of e.g. a QStandardItem in a QStandardItemModel visualized by some view (with a QSortFilterProxyModel in between) does update the view immediately.
    How can I make the view update whenever the data of the underlying model changes?

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

      Hi,

      By triggering the appropriate signal at the right time from the model to notify the view that something is happening. Essentially emit dataChanged from 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
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        When the data in the source model is changed, the proxy model knows about it (without me needing to emit the signal manually). How does that happen and why doesn't the view make use of the same feature? Can I somehow abuse that behaviour?

        I will try to apply your suggestion, but the current structure of the program might make that a little difficult.

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

          Since you are loading the icons in another thread, once an icon is loaded, signal that to your model, and from within the model trigger the dataChanged signal accordingly then you should be good to go.

          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

          • Login

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