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

How to notify QtreeView to refresh

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 10.2k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #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

    RatzzR raven-worxR 2 Replies Last reply
    0
    • Q Qt Enthusiast

      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

      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on 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

        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

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #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
        • -AVM- Offline
          -AVM- Offline
          -AVM
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on 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

            raven-worxR 1 Reply Last reply
            0
            • Q Qt Enthusiast

              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

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on 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

              • Login

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