Search code examples
qt5repaintqtableviewqtimer

How can I trigger the redraw of a QTableView inQt5?


I have implemented a simple QAbstractTableModel and attached it to a QTableView in Qt5. How can I trigger a repaint from a timer? The data changes every second?

My naïve attempt does not work (no repaint occurs):

connect(timer,SIGNAL(timeout()),table,SLOT(update()));
timer->start(1000);

Solution

  • When data changes you should emit the dataChanged signal from the model.