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 refresh the QTreeView and QtableView
Qt 6.11 is out! See what's new in the release blog

how to refresh the QTreeView and QtableView

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.6k Views 3 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 last edited by
    #1

    0_1543259186354_Table1.png

    I have DIalog

    1. QTreeview with Custom Model
    2. QTableView with Custom Model

    on clicking on Finding , I have to refresh the both Qtreeview and QTableview .

    A
    B
    C

    D
    E
    F

    1. How to ask the QAbstractModel to start fetching the data again

    Can someone help me in writing the refresh functions for both

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      [protected] void QAbstractItemModel::beginResetModel()
      Begins a model reset operation.
      A reset operation resets the model to its current state in any attached views.
      Note: Any views attached to this model will be reset as well.
      When a model is reset it means that any previous data reported from the model is now invalid and has to be queried for again. This also means that the current item and any selected items will become invalid.
      When a model radically changes its data it can sometimes be easier to just call this function rather than emit dataChanged() to inform other components when the underlying data source, or its structure, has changed.
      You must call this function before resetting any internal data structures in your model or proxy model.
      This function emits the signal modelAboutToBeReset().
      This function was introduced in Qt 4.6.
      See also modelAboutToBeReset(), modelReset(), and endResetModel().

      1 Reply Last reply
      1
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Maybe you could inherit from QSortFilterProxyModel, code the find method according to some internal criteria and use it for both views?

        Here is an exemple: http://doc.qt.io/qt-5/qtwidgets-itemviews-customsortfiltermodel-example.html

        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