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. [Solved]Custom TableModel and redraw View data
Qt 6.11 is out! See what's new in the release blog

[Solved]Custom TableModel and redraw View data

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.5k 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
    qxoz
    wrote on last edited by
    #1

    Hi everyone!
    I have some raw data, and CustomTableModel which build table from it. Data frequently updated from remote source. Model knows it, and should send some signal to a view for redraw all data. I expect from my model, QSqlTableModel like behavior. Emitting dataChanged() signal has no effect, calling beginInser() and endInsert methods too. Only setModel for a view works for now. I look at QSqlTableModel code but cant figure out how model send update signal to view. Can you tell me please what is right solution of this issue.

    Thank you!

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Let me close my own question.
      When you add new rows to the model use:
      @beginInsertRows();
      //Adding new rows
      endInsertRows();@
      when you remove rows:
      @beginRemoveRows();
      //Removing rows
      endRemoveRows();@
      in your case when you reload all data you can use:
      @beginResetModel();
      //Removing rows
      endResetModel();@
      Emitting dataChanged() useful if you change value of already existing item

      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