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. How to notify QtreeView to refresh
Forum Updated to NodeBB v4.3 + New Features

How to notify QtreeView to refresh

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 10.3k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on 5 Jul 2016, 03:48 last edited by Qt Enthusiast 7 May 2016, 03:48
    #1

    I have a two views .

    1. One is of QGraphicsView and other is QTreeView with custommodel .
    2. I make some changes in QTreeView. I want to notify the QTreeView that data is updated and QTreeView should start fetching data again . Means its custom model should call ::data

    Can some one guide me how to the same through code

    R R 2 Replies Last reply 5 Jul 2016, 04:52
    0
    • Q Qt Enthusiast
      5 Jul 2016, 03:48

      I have a two views .

      1. One is of QGraphicsView and other is QTreeView with custommodel .
      2. I make some changes in QTreeView. I want to notify the QTreeView that data is updated and QTreeView should start fetching data again . Means its custom model should call ::data

      Can some one guide me how to the same through code

      R Offline
      R Offline
      Ratzz
      wrote on 5 Jul 2016, 04:52 last edited by
      #2

      @Qt-Enthusiast
      You can refresh model using http://doc.qt.io/qt-4.8/qabstractitemmodel.html#layoutChanged .

      --Alles ist gut.

      1 Reply Last reply
      1
      • Q Qt Enthusiast
        5 Jul 2016, 03:48

        I have a two views .

        1. One is of QGraphicsView and other is QTreeView with custommodel .
        2. I make some changes in QTreeView. I want to notify the QTreeView that data is updated and QTreeView should start fetching data again . Means its custom model should call ::data

        Can some one guide me how to the same through code

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 5 Jul 2016, 05:58 last edited by raven-worx 7 May 2016, 05:59
        #3

        @Qt-Enthusiast
        in your setData() method (or wherever you change your data) you need to emit QAbstractItemModel's dataChanged() signal for the indexes which have changed.

        @Ratzz
        i works because a relayout implies also a repaint which regathers the data again from the model, but i wouldn't use layoutChanged() since the layout is simply not necessary.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • - Offline
          - Offline
          -AVM
          wrote on 5 Jul 2016, 07:19 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on 5 Jul 2016, 09:49 last edited by
            #5

            One more case If I make any changes in QGraphicsView and if from QGraphicsView, If I want to notify QTreeView that please update the view and get new data from ::data . Can some one guide me on this

            R 1 Reply Last reply 5 Jul 2016, 10:13
            0
            • Q Qt Enthusiast
              5 Jul 2016, 09:49

              One more case If I make any changes in QGraphicsView and if from QGraphicsView, If I want to notify QTreeView that please update the view and get new data from ::data . Can some one guide me on this

              R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 5 Jul 2016, 10:13 last edited by
              #6

              @Qt-Enthusiast
              you need to be more specific...

              The model handles the data. Whenever the data in the model changes emit dataChanged(). And every view which uses the model will get updated.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1

              4/6

              5 Jul 2016, 07:19

              • Login

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