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 update a model so it refreshes all its views?
QtWS25 Last Chance

How to update a model so it refreshes all its views?

Scheduled Pinned Locked Moved Unsolved General and Desktop
model view prog
2 Posts 2 Posters 195 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.
  • J Offline
    J Offline
    jdent
    wrote on 5 Aug 2024, 23:42 last edited by
    #1

    I have a QAbstractTableModel subclass and i want to tell the model that it has been modified so that all its views are refreshed. Currently I have this trick which refreshes but it only refreshes one QTableView:

        model->setData(insertIndex, QVariant(-1), Qt::EditRole);
        ui.tableView->setCurrentIndex(insertIndex);
    

    There must be a more general method at the model level!

    C 1 Reply Last reply 6 Aug 2024, 00:22
    0
    • J jdent
      5 Aug 2024, 23:42

      I have a QAbstractTableModel subclass and i want to tell the model that it has been modified so that all its views are refreshed. Currently I have this trick which refreshes but it only refreshes one QTableView:

          model->setData(insertIndex, QVariant(-1), Qt::EditRole);
          ui.tableView->setCurrentIndex(insertIndex);
      

      There must be a more general method at the model level!

      C Offline
      C Offline
      ChrisW67
      wrote on 6 Aug 2024, 00:22 last edited by
      #2

      Your class implementation of, for example, QAbstractItemModel::setData() should emit the dataChanged() signal. It is all fairly well described in subclassing.

      1 Reply Last reply
      6

      1/2

      5 Aug 2024, 23:42

      • Login

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