Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. QTreeView, QAbstractItemModel and refreshing view
Forum Updated to NodeBB v4.3 + New Features

QTreeView, QAbstractItemModel and refreshing view

Scheduled Pinned Locked Moved Language Bindings
6 Posts 2 Posters 4.4k 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.
  • F Offline
    F Offline
    farcat
    wrote on last edited by
    #1

    Hi all,

    I am trying to find a way to refresh a QTreeView when the flags of the items in the QAbstractItemModel change (the model doe not change), but i cannot figure it out. I notice that when i enter the QTreeView with the mouse the refresh takes place, but i don't know what happens in the background. Calling repaint() does not seem to work.

    Can anyone help?

    Cheers, Lars

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

      Hi,

      I would try with the "dataChanged":http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#dataChanged

      Hope it helps

      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
      • F Offline
        F Offline
        farcat
        wrote on last edited by
        #3

        I tried that, but couldnt figure it out,e.g. where do i get the index parameters, especially in a tree model?

        CL

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

          Don't you have these indexes when changing the flags ?

          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
          • F Offline
            F Offline
            farcat
            wrote on last edited by
            #5

            As far as i know, the view the view gets the flags from the model per index. However my flags(index) method calculates the flags based on what is shown somewhere else (the user drags items from the treeview to a canvas, but depending on what is shown on the canvas not all items in the tree make sense to be dragged). So i want a number of items in the tree to be disabled (but visible) when the content of the canvas changes. i have a signal for that, which should (also) result in refreshing the treeview so all flags are recalculated.

            Cheers, Lars

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

              Then maybe layoutChanged would be more appropriated

              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